Class: Plurimath::Math::Symbol

Inherits:
Object
  • Object
show all
Defined in:
lib/plurimath/math/symbol.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#valueObject

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

#mathml_symbol_valueObject



24
25
26
# File 'lib/plurimath/math/symbol.rb', line 24

def mathml_symbol_value
  Mathml::Constants::UNICODE_SYMBOLS.invert[value] || value
end

#to_asciimathObject



16
17
18
# File 'lib/plurimath/math/symbol.rb', line 16

def to_asciimath
  value
end

#to_latexObject



28
29
30
31
# File 'lib/plurimath/math/symbol.rb', line 28

def to_latex
  symbols = Latex::Constants::SYMBOLS
  symbols.include?(value) ? "\\#{value}" : value
end

#to_mathml_without_math_tagObject



20
21
22
# File 'lib/plurimath/math/symbol.rb', line 20

def to_mathml_without_math_tag
  "<mo>#{mathml_symbol_value}</mo>"
end