Class: Memo::Option
- Inherits:
-
Object
- Object
- Memo::Option
- Defined in:
- lib/memo/cli/arg/option.rb
Instance Attribute Summary collapse
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
Instance Method Summary collapse
- #[](index) ⇒ Object
- #all? ⇒ Boolean
- #copy? ⇒ Boolean
- #dir? ⇒ Boolean
-
#initialize(args) ⇒ Option
constructor
A new instance of Option.
Constructor Details
#initialize(args) ⇒ Option
Returns a new instance of Option.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/memo/cli/arg/option.rb', line 5 def initialize(args) @raw_args = args.to_a case @raw_args in [*, "-n", namespace, *] @namespace = namespace @raw_args.delete("-n") @raw_args.delete(namespace) else end @args = @raw_args.select do |s| !s.start_with? "-" end end |
Instance Attribute Details
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
3 4 5 |
# File 'lib/memo/cli/arg/option.rb', line 3 def namespace @namespace end |
Instance Method Details
#[](index) ⇒ Object
21 22 23 |
# File 'lib/memo/cli/arg/option.rb', line 21 def [](index) @args[index] end |
#all? ⇒ Boolean
29 30 31 |
# File 'lib/memo/cli/arg/option.rb', line 29 def all? include_any? "-all", "-a" end |
#copy? ⇒ Boolean
33 34 35 |
# File 'lib/memo/cli/arg/option.rb', line 33 def copy? include_any? "-copy", "-c" end |
#dir? ⇒ Boolean
25 26 27 |
# File 'lib/memo/cli/arg/option.rb', line 25 def dir? include_any? "-dir", "-d" end |