Class: Eco::API::UseCases::Cli::Option

Inherits:
Object
  • Object
show all
Defined in:
lib/eco/api/usecases/cli/option.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#callbackObject

Returns the value of attribute callback.



4
5
6
# File 'lib/eco/api/usecases/cli/option.rb', line 4

def callback
  @callback
end

#descObject

Returns the value of attribute desc.



4
5
6
# File 'lib/eco/api/usecases/cli/option.rb', line 4

def desc
  @desc
end

#nameObject

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

Raises:

  • (ArgumentError)


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