Class: EacCli::Definition::OptionOrPositional Abstract
- Defined in:
- lib/eac_cli/definition/option_or_positional.rb
Overview
This class is abstract.
Direct Known Subclasses
Constant Summary collapse
- OPTION_LIST =
i[optional repeat required].freeze
Instance Method Summary collapse
Instance Method Details
#optional? ⇒ Boolean
13 14 15 |
# File 'lib/eac_cli/definition/option_or_positional.rb', line 13 def optional? !required? end |
#raise(*args) ⇒ Object
18 19 20 |
# File 'lib/eac_cli/definition/option_or_positional.rb', line 18 def raise(*args) ::Kernel.raise ::EacCli::Definition::Error, *args end |
#repeat? ⇒ Boolean
23 24 25 |
# File 'lib/eac_cli/definition/option_or_positional.rb', line 23 def repeat? [:repeat] ? true : false end |
#required? ⇒ Boolean
28 29 30 31 32 33 |
# File 'lib/eac_cli/definition/option_or_positional.rb', line 28 def required? return true if .key?(:required) && .fetch(:required) return false if .key?(:optional) && .fetch(:optional) self.class.const_get('DEFAULT_REQUIRED') end |
#to_s ⇒ String
36 37 38 |
# File 'lib/eac_cli/definition/option_or_positional.rb', line 36 def to_s "#{self.class.name.demodulize}[#{identifier}]" end |