Class: Plurimath::Math::Symbol
- Defined in:
- lib/plurimath/math/symbol.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #==(object) ⇒ Object
-
#initialize(sym) ⇒ Symbol
constructor
A new instance of Symbol.
- #to_asciimath ⇒ Object
- #to_html ⇒ Object
- #to_latex ⇒ Object
- #to_mathml_without_math_tag ⇒ Object
- #to_omml_without_math_tag ⇒ Object
Methods inherited from Base
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 = super 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 |
#to_asciimath ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/plurimath/math/symbol.rb', line 16 def to_asciimath return "" if value.nil? symbol = Asciimath::Constants::SYMBOLS.invert[value.strip.to_sym] unicodes = Latex::Constants::UNICODE_SYMBOLS.invert if value.match?(/&#x[0-9\w]+;/) && symbol.nil? && unicodes[value] return unicodes[value].to_s end symbol ? symbol.to_s : value end |
#to_html ⇒ Object
57 58 59 |
# File 'lib/plurimath/math/symbol.rb', line 57 def to_html value end |
#to_latex ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/plurimath/math/symbol.rb', line 42 def to_latex returned = specific_values return returned if returned special_char = %w[& #] symbols = Latex::Constants::UNICODE_SYMBOLS.invert symbol = symbols[value] if Latex::Constants::SYMBOLS[symbol] == :operant special_char.include?(value) ? "\\#{symbol}" : symbol else symbols.key?(value) ? "\\#{symbol}" : value end end |
#to_mathml_without_math_tag ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/plurimath/math/symbol.rb', line 28 def to_mathml_without_math_tag mi_tag = Utility.ox_element("mi") return mi_tag if ["{:", ":}"].include?(value) unicodes = Mathml::Constants::UNICODE_SYMBOLS unicode = unicodes.invert[value] if operator?(unicode) || unicode mo_value = (unicodes[value] || unicode || value).to_s return Utility.ox_element("mo") << mo_value end mi_tag << value end |
#to_omml_without_math_tag ⇒ Object
61 62 63 |
# File 'lib/plurimath/math/symbol.rb', line 61 def to_omml_without_math_tag value end |