Module: Ruby::Alternation::ArgsList

Included in:
Ruby::ArgsList
Defined in:
lib/ruby/alternation/args.rb

Instance Method Summary collapse

Instance Method Details

#optionsObject



4
5
6
# File 'lib/ruby/alternation/args.rb', line 4

def options
  last.arg.is_a?(Ruby::Hash) ? last : nil
end

#set_option(key, value) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/ruby/alternation/args.rb', line 8

def set_option(key, value)
  if options.nil?
    # TODO gotta add a separator as well, so maybe better replace the whole options hash
    self << to_node({key => value}, position.tap { |p| p[1] += length })
  else
    options[key] = to_node(value, options[key].position, options[key].prolog)
  end
end