Class: Lab419::Options::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/lab419/options/parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dataObject

Returns the value of attribute data.



4
5
6
# File 'lib/lab419/options/parser.rb', line 4

def data
  @data
end

#kwdsObject

Returns the value of attribute kwds.



4
5
6
# File 'lib/lab419/options/parser.rb', line 4

def kwds
  @kwds
end

#positionalsObject

Returns the value of attribute positionals.



4
5
6
# File 'lib/lab419/options/parser.rb', line 4

def positionals
  @positionals
end

Instance Method Details

#parse(args) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/lab419/options/parser.rb', line 5

def parse args
  self.data = {to_a: args}
  self.kwds = {}
  self.positionals = []
  parse_all args
  data.merge kwds: OpenStruct.new(kwds), args: positionals
end