Class: Plurimath::Math::Formula
- Inherits:
-
Object
- Object
- Plurimath::Math::Formula
- Defined in:
- lib/plurimath/math/formula.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #==(object) ⇒ Object
- #class_name ⇒ Object
-
#initialize(value = []) ⇒ Formula
constructor
A new instance of Formula.
- #mathml_content ⇒ Object
- #to_asciimath ⇒ Object
- #to_html ⇒ Object
- #to_latex ⇒ Object
- #to_mathml ⇒ Object
- #to_mathml_without_math_tag ⇒ Object
Constructor Details
#initialize(value = []) ⇒ Formula
Returns a new instance of Formula.
8 9 10 |
# File 'lib/plurimath/math/formula.rb', line 8 def initialize(value = []) @value = value.is_a?(Array) ? value : [value] end |
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
6 7 8 |
# File 'lib/plurimath/math/formula.rb', line 6 def value @value end |
Instance Method Details
#==(object) ⇒ Object
12 13 14 |
# File 'lib/plurimath/math/formula.rb', line 12 def ==(object) object.value == value end |
#class_name ⇒ Object
46 47 48 |
# File 'lib/plurimath/math/formula.rb', line 46 def class_name "formula" end |
#mathml_content ⇒ Object
34 35 36 |
# File 'lib/plurimath/math/formula.rb', line 34 def mathml_content value.map(&:to_mathml_without_math_tag).join end |
#to_asciimath ⇒ Object
16 17 18 |
# File 'lib/plurimath/math/formula.rb', line 16 def to_asciimath value.map(&:to_asciimath).join end |
#to_html ⇒ Object
42 43 44 |
# File 'lib/plurimath/math/formula.rb', line 42 def to_html value.map(&:to_html).join end |
#to_latex ⇒ Object
38 39 40 |
# File 'lib/plurimath/math/formula.rb', line 38 def to_latex value.map(&:to_latex).join end |
#to_mathml ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/plurimath/math/formula.rb', line 20 def to_mathml <<~MATHML <math xmlns='http://www.w3.org/1998/Math/MathML' display='block'> <mstyle displaystyle='true'> #{mathml_content} </mstyle> </math> MATHML end |
#to_mathml_without_math_tag ⇒ Object
30 31 32 |
# File 'lib/plurimath/math/formula.rb', line 30 def to_mathml_without_math_tag "<mrow>#{mathml_content}</mrow>" end |