Class: Sts::IsoSts::Mathml2::Math

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Defined in:
lib/sts/iso_sts/mathml2/math.rb

Constant Summary collapse

MATH_NS =
"http://www.w3.org/1998/Math/MathML"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_xml(input) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/sts/iso_sts/mathml2/math.rb', line 27

def self.from_xml(input)
  input_str = input.respond_to?(:read) ? input.read : input.to_s

  doc = parse_with_namespace(input_str)
  math_element = find_math_element(doc)
  return new if math_element.nil?

  math = new
  math.id = math_element["id"]
  math.display = math_element["display"]
  math.content = extract_inner_content(math_element)
  math.instance_variable_set(:@original_xml, math_element.to_xml)
  math
end

Instance Method Details

#to_xmlObject



23
24
25
# File 'lib/sts/iso_sts/mathml2/math.rb', line 23

def to_xml(*)
  @original_xml || %{<math xmlns="#{MATH_NS}"/>}
end