Class: EacCli::Definition::BaseOption
- Inherits:
-
Object
- Object
- EacCli::Definition::BaseOption
show all
- Defined in:
- lib/eac_cli/definition/base_option.rb,
lib/eac_cli/definition/base_option/initialize_args_parser.rb
Defined Under Namespace
Classes: InitializeArgsParser
Constant Summary
collapse
- DEFAULT_REQUIRED =
false
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Method Details
#default_value ⇒ Object
30
31
32
|
# File 'lib/eac_cli/definition/base_option.rb', line 30
def default_value
default_value? ? options[OPTION_DEFAULT] : default_default_value
end
|
#default_value? ⇒ Boolean
34
35
36
|
# File 'lib/eac_cli/definition/base_option.rb', line 34
def default_value?
options.key?(OPTION_DEFAULT)
end
|
#identifier ⇒ Object
38
39
40
41
42
43
44
|
# File 'lib/eac_cli/definition/base_option.rb', line 38
def identifier
[long, short].each do |v|
v.to_s.if_present { |vv| return vv.variableize.to_sym }
end
raise 'No short or long option to build identifier'
end
|
#repeat? ⇒ Boolean
46
47
48
|
# File 'lib/eac_cli/definition/base_option.rb', line 46
def repeat?
options[OPTION_REPEAT]
end
|
#required? ⇒ Boolean
50
51
52
53
54
55
|
# File 'lib/eac_cli/definition/base_option.rb', line 50
def required?
return true if options.key?(:required) && options.fetch(:required)
return false if options.key?(:optional) && options.fetch(:optional)
DEFAULT_REQUIRED
end
|
#show_on_usage? ⇒ Boolean
61
62
63
|
# File 'lib/eac_cli/definition/base_option.rb', line 61
def show_on_usage?
options[:usage]
end
|
57
58
59
|
# File 'lib/eac_cli/definition/base_option.rb', line 57
def to_s
"#{self.class.name.demodulize}[#{identifier}]"
end
|