Class: Plurimath::Math::Symbol
- Inherits:
-
Object
- Object
- Plurimath::Math::Symbol
- Defined in:
- lib/plurimath/math/symbol.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #==(object) ⇒ Object
- #class_name ⇒ Object
-
#initialize(sym) ⇒ Symbol
constructor
A new instance of Symbol.
- #mathml_symbol_value ⇒ Object
- #to_asciimath ⇒ Object
- #to_html ⇒ Object
- #to_latex ⇒ Object
- #to_mathml_without_math_tag ⇒ Object
Constructor Details
#initialize(sym) ⇒ Symbol
Returns a new instance of Symbol.
8 9 10 |
# File 'lib/plurimath/math/symbol.rb', line 8 def initialize(sym) @value = sym end |
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
6 7 8 |
# File 'lib/plurimath/math/symbol.rb', line 6 def value @value end |
Instance Method Details
#==(object) ⇒ Object
12 13 14 |
# File 'lib/plurimath/math/symbol.rb', line 12 def ==(object) object.value == value end |
#class_name ⇒ Object
38 39 40 |
# File 'lib/plurimath/math/symbol.rb', line 38 def class_name self.class.name.split("::").last.downcase end |
#mathml_symbol_value ⇒ Object
25 26 27 |
# File 'lib/plurimath/math/symbol.rb', line 25 def mathml_symbol_value Mathml::Constants::UNICODE_SYMBOLS.invert[value] || value end |
#to_asciimath ⇒ Object
16 17 18 19 |
# File 'lib/plurimath/math/symbol.rb', line 16 def to_asciimath symbol = Asciimath::Constants::SYMBOLS.invert[value.to_sym].to_s symbol.empty? ? value : symbol end |
#to_html ⇒ Object
34 35 36 |
# File 'lib/plurimath/math/symbol.rb', line 34 def to_html value end |
#to_latex ⇒ Object
29 30 31 32 |
# File 'lib/plurimath/math/symbol.rb', line 29 def to_latex symbols = Latex::Constants::SYMBOLS.invert symbols.key?(value) ? "\\#{symbols[value]}" : value end |
#to_mathml_without_math_tag ⇒ Object
21 22 23 |
# File 'lib/plurimath/math/symbol.rb', line 21 def to_mathml_without_math_tag "<mo>#{mathml_symbol_value}</mo>" end |