Class: Plurimath::Math::Function::Text

Inherits:
UnaryFunction show all
Defined in:
lib/plurimath/math/function/text.rb

Instance Attribute Summary

Attributes inherited from UnaryFunction

#parameter_one

Instance Method Summary collapse

Methods inherited from UnaryFunction

#==, #class_name, #initialize, #value_to_asciimath

Constructor Details

This class inherits a constructor from Plurimath::Math::Function::UnaryFunction

Instance Method Details

#symbol_value(unicode) ⇒ Object



21
22
23
24
# File 'lib/plurimath/math/function/text.rb', line 21

def symbol_value(unicode)
  Mathml::Constants::UNICODE_SYMBOLS.invert[unicode] ||
    Mathml::Constants::SYMBOLS.invert[unicode]
end

#to_asciimathObject



9
10
11
# File 'lib/plurimath/math/function/text.rb', line 9

def to_asciimath
  "\"#{parameter_one}\""
end

#to_latexObject



26
27
28
# File 'lib/plurimath/math/function/text.rb', line 26

def to_latex
  parameter_one
end

#to_mathml_without_math_tagObject



13
14
15
16
17
18
19
# File 'lib/plurimath/math/function/text.rb', line 13

def to_mathml_without_math_tag
  regex_exp = %r{unicode\[:(?<unicode>\w{1,})\]}
  parameter_one.gsub!(regex_exp) do |_text|
    symbol_value(Regexp.last_match[:unicode]).to_s
  end
  "<mtext>#{parameter_one}</mtext>"
end