Class: Mathml2latex::MathmlLatexService

Inherits:
Object
  • Object
show all
Defined in:
lib/mathml2latex/mathml_latex_service.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.xsltObject

Returns the value of attribute xslt.


28
29
30
# File 'lib/mathml2latex/mathml_latex_service.rb', line 28

def xslt
  @xslt
end

Class Method Details

.get_service_objectObject

rubocop:disable Naming/AccessorMethodName

[View source]

11
12
13
14
# File 'lib/mathml2latex/mathml_latex_service.rb', line 11

def self.get_service_object # rubocop:disable Naming/AccessorMethodName
  setup_xslt
  new
end

Instance Method Details

#to_latex(mathml) ⇒ Object

[View source]

21
22
23
24
25
# File 'lib/mathml2latex/mathml_latex_service.rb', line 21

def to_latex(mathml)
  doc = Nokogiri::XML(mathml)
  result = self.class.xslt.transform(doc)
  result.at_xpath('//text()').text
end

#to_latex_from_file(mathml_file) ⇒ Object

[View source]

16
17
18
19
# File 'lib/mathml2latex/mathml_latex_service.rb', line 16

def to_latex_from_file(mathml_file)
  mathml = File.open(mathml_file)
  to_latex(mathml)
end