Class: Sts::Mathml::Math

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Defined in:
lib/sts/niso_sts/mathml.rb

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object

Forward missing methods to the underlying math object



42
43
44
45
46
47
48
# File 'lib/sts/niso_sts/mathml.rb', line 42

def method_missing(method_name, *args, &block)
  if math.respond_to?(method_name)
    math.send(method_name, *args, &block)
  else
    super
  end
end

Class Method Details

.from_xml(input) ⇒ Object



58
59
60
61
62
63
64
65
66
# File 'lib/sts/niso_sts/mathml.rb', line 58

def self.from_xml(input)
  # Parse the inner math element and wrap it
  parsed = Mml::V3::Math.from_xml(input)
  math = new
  math.instance_variable_set(:@math, parsed)
  math.id = parsed.id
  math.display = parsed.display
  math
end

Instance Method Details

#displayObject



32
33
34
# File 'lib/sts/niso_sts/mathml.rb', line 32

def display
  @display ||= math&.display
end

#display=(value) ⇒ Object



36
37
38
39
# File 'lib/sts/niso_sts/mathml.rb', line 36

def display=(value)
  @display = value
  math.display = value if math
end

#idObject



23
24
25
# File 'lib/sts/niso_sts/mathml.rb', line 23

def id
  @id ||= math&.id
end

#id=(value) ⇒ Object



27
28
29
30
# File 'lib/sts/niso_sts/mathml.rb', line 27

def id=(value)
  @id = value
  math.id = value if math
end

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/sts/niso_sts/mathml.rb', line 50

def respond_to_missing?(method_name, include_private = false)
  math.respond_to?(method_name, include_private) || super
end

#to_xmlObject



54
55
56
# File 'lib/sts/niso_sts/mathml.rb', line 54

def to_xml
  math&.to_xml
end