Module: Map::Arguments

Defined in:
lib/map/options.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.for(args) ⇒ Object


147
148
149
150
# File 'lib/map/options.rb', line 147

def for(args)
  args.extend(Arguments) unless args.is_a?(Arguments)
  args
end

.parse(args) ⇒ Object


152
153
154
# File 'lib/map/options.rb', line 152

def parse(args)
  [args, Options.parse(args)]
end

Instance Method Details

#optionsObject


131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/map/options.rb', line 131

def options
  @options ||=(
    if last.is_a?(Hash)
      options = Options.for(pop)
      options.arguments = self
      push(options)
      options
    else
      options = Options.for({})
      options.arguments = self
      options
    end
  )
end