Class: ParticleCMD::Info
- Inherits:
-
Object
- Object
- ParticleCMD::Info
- Defined in:
- lib/particlecmd/info.rb
Instance Attribute Summary collapse
-
#argv ⇒ Object
Returns the value of attribute argv.
-
#flags ⇒ Object
Returns the value of attribute flags.
-
#options ⇒ Object
Returns the value of attribute options.
-
#positionals ⇒ Object
Returns the value of attribute positionals.
Instance Method Summary collapse
-
#initialize(argv) ⇒ Info
constructor
A new instance of Info.
Constructor Details
#initialize(argv) ⇒ Info
Returns a new instance of Info.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/particlecmd/info.rb', line 4 def initialize(argv) @argv = argv @positionals = [] @flags = [] @options = {} argv.each do |word| if word[0] == '-' i = word.match(/-+(.+?)(=(.+))?$/) if i[3] @options[i[1]] = i[3] else @flags << i[1] end else @positionals << word end end end |
Instance Attribute Details
#argv ⇒ Object
Returns the value of attribute argv.
2 3 4 |
# File 'lib/particlecmd/info.rb', line 2 def argv @argv end |
#flags ⇒ Object
Returns the value of attribute flags.
2 3 4 |
# File 'lib/particlecmd/info.rb', line 2 def flags @flags end |
#options ⇒ Object
Returns the value of attribute options.
2 3 4 |
# File 'lib/particlecmd/info.rb', line 2 def @options end |
#positionals ⇒ Object
Returns the value of attribute positionals.
2 3 4 |
# File 'lib/particlecmd/info.rb', line 2 def positionals @positionals end |