Class: Eco::API::UseCases::Cli::Option
- Defined in:
- lib/eco/api/usecases/cli/option.rb
Instance Attribute Summary collapse
-
#callback ⇒ Object
Returns the value of attribute callback.
-
#desc ⇒ Object
Returns the value of attribute desc.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #dup(name: self.name, desc: self.desc, &block) ⇒ Object
-
#initialize(name, desc, &block) ⇒ Option
constructor
A new instance of Option.
- #link_case(cli_config_case) ⇒ Object
Constructor Details
#initialize(name, desc, &block) ⇒ Option
Returns a new instance of Option.
6 7 8 |
# File 'lib/eco/api/usecases/cli/option.rb', line 6 def initialize(name, desc, &block) @name, @desc, @callback = name, desc, block end |
Instance Attribute Details
#callback ⇒ Object
Returns the value of attribute callback.
4 5 6 |
# File 'lib/eco/api/usecases/cli/option.rb', line 4 def callback @callback end |
#desc ⇒ Object
Returns the value of attribute desc.
4 5 6 |
# File 'lib/eco/api/usecases/cli/option.rb', line 4 def desc @desc end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/eco/api/usecases/cli/option.rb', line 4 def name @name end |
Instance Method Details
#dup(name: self.name, desc: self.desc, &block) ⇒ Object
10 11 12 |
# File 'lib/eco/api/usecases/cli/option.rb', line 10 def dup(name: self.name, desc: self.desc, &block) self.class.new(name, desc, &(block || callback)) end |
#link_case(cli_config_case) ⇒ Object
14 15 16 17 18 |
# File 'lib/eco/api/usecases/cli/option.rb', line 14 def link_case(cli_config_case) raise ArgumentError, "cli_config_case must have an 'add_option' method. Given: #{cli_config_case.class}" unless cli_config_case.respond_to?(:add_option) cli_config_case.add_option(name, desc, &callback) end |