Class: Plurimath::Omml::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/plurimath/omml/parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ Parser

Returns a new instance of Parser.



10
11
12
# File 'lib/plurimath/omml/parser.rb', line 10

def initialize(text)
  @text = CGI.unescape(text)
end

Instance Attribute Details

#textObject

Returns the value of attribute text.



8
9
10
# File 'lib/plurimath/omml/parser.rb', line 8

def text
  @text
end

Instance Method Details

#parseObject



14
15
16
17
18
19
# File 'lib/plurimath/omml/parser.rb', line 14

def parse
  nodes = Ox.load(text, mode: :hash, strip_namespace: true)
  Math::Formula.new(
    Transform.new.apply(nodes),
  )
end