Class: Tomo::CLI::Options
- Inherits:
-
Object
- Object
- Tomo::CLI::Options
- Defined in:
- lib/tomo/cli/options.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #all(key) ⇒ Object
- #any? ⇒ Boolean
- #fetch(key, default) ⇒ Object
-
#initialize ⇒ Options
constructor
A new instance of Options.
- #key?(key) ⇒ Boolean
Constructor Details
#initialize ⇒ Options
Returns a new instance of Options.
6 7 8 |
# File 'lib/tomo/cli/options.rb', line 6 def initialize @options = {} end |
Instance Method Details
#[](key) ⇒ Object
23 24 25 |
# File 'lib/tomo/cli/options.rb', line 23 def [](key) fetch(key, nil) end |
#[]=(key, value) ⇒ Object
27 28 29 |
# File 'lib/tomo/cli/options.rb', line 27 def []=(key, value) all(key).clear.push(value) end |
#all(key) ⇒ Object
31 32 33 |
# File 'lib/tomo/cli/options.rb', line 31 def all(key) [key] ||= [] end |
#any? ⇒ Boolean
10 11 12 |
# File 'lib/tomo/cli/options.rb', line 10 def any? .any? end |
#fetch(key, default) ⇒ Object
18 19 20 21 |
# File 'lib/tomo/cli/options.rb', line 18 def fetch(key, default) values = all(key) values.empty? ? default : values.first end |
#key?(key) ⇒ Boolean
14 15 16 |
# File 'lib/tomo/cli/options.rb', line 14 def key?(key) !all(key).empty? end |