Class: Kuby::Args
- Inherits:
-
Object
- Object
- Kuby::Args
- Defined in:
- lib/kuby/rails_commands.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#flag_aliases ⇒ Object
readonly
Returns the value of attribute flag_aliases.
Instance Method Summary collapse
- #[](flag) ⇒ Object
- #[]=(flag, new_value) ⇒ Object
-
#initialize(args, flag_aliases = []) ⇒ Args
constructor
A new instance of Args.
Constructor Details
#initialize(args, flag_aliases = []) ⇒ Args
Returns a new instance of Args.
6 7 8 9 |
# File 'lib/kuby/rails_commands.rb', line 6 def initialize(args, flag_aliases = []) @args = args @flag_aliases = flag_aliases end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
4 5 6 |
# File 'lib/kuby/rails_commands.rb', line 4 def args @args end |
#flag_aliases ⇒ Object (readonly)
Returns the value of attribute flag_aliases.
4 5 6 |
# File 'lib/kuby/rails_commands.rb', line 4 def flag_aliases @flag_aliases end |
Instance Method Details
#[](flag) ⇒ Object
11 12 13 14 |
# File 'lib/kuby/rails_commands.rb', line 11 def [](flag) idx = find_arg_index(flag) idx ? args[idx] : nil end |
#[]=(flag, new_value) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/kuby/rails_commands.rb', line 16 def []=(flag, new_value) idx = find_arg_index(flag) if idx args[idx] = new_value else @args += [flag, new_value] end end |