Class: Eco::CLI::Scripting::Argument
- Defined in:
- lib/eco/cli/scripting/argument.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Class Method Summary collapse
Instance Method Summary collapse
- #args_slice(*args) ⇒ Object
-
#initialize(key, with_param: false) ⇒ Argument
constructor
A new instance of Argument.
- #with_param! ⇒ Object
- #with_param? ⇒ Boolean
Constructor Details
#initialize(key, with_param: false) ⇒ Argument
Returns a new instance of Argument.
14 15 16 17 |
# File 'lib/eco/cli/scripting/argument.rb', line 14 def initialize(key, with_param: false) @key = key @with_param = !!with_param end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
6 7 8 |
# File 'lib/eco/cli/scripting/argument.rb', line 6 def key @key end |
Class Method Details
.is_modifier?(value) ⇒ Boolean
9 10 11 |
# File 'lib/eco/cli/scripting/argument.rb', line 9 def is_modifier?(value) value&.start_with?("-") end |
Instance Method Details
#args_slice(*args) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/eco/cli/scripting/argument.rb', line 19 def args_slice(*args) #pp "known arg '#{key}' => included? #{args.include?(key)}" return args unless args.include?(key) i = args.index(key) j = with_param?? i+1 : i args - args.slice(i..j) end |
#with_param! ⇒ Object
27 28 29 |
# File 'lib/eco/cli/scripting/argument.rb', line 27 def with_param! @with_param = true end |
#with_param? ⇒ Boolean
31 32 33 |
# File 'lib/eco/cli/scripting/argument.rb', line 31 def with_param? @with_param end |