Class: Rulex::Tex::Grammar::Command

Inherits:
CustomNode
  • Object
show all
Defined in:
lib/rulex/tex/node_extensions.rb

Instance Method Summary collapse

Instance Method Details

#contentObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/rulex/tex/node_extensions.rb', line 33

def content
  h = {type: :command, name: elements[1].text_value}
  if opts_maybe = elements[2].elements
    opts = []
    opts << opts_maybe[1].text_value

    if opts_kleene_s = opts_maybe[2].elements
      opts += opts_kleene_s.map{|e| e.elements[1].text_value}
    end

    h.merge!(options: opts)
  end
  if args_kleene_s = elements[3]
    h.merge!(arguments: args_kleene_s.elements.map{|e| e.elements[1].text_value}) 
  end

  h
end