Class: Plurimath::Math::Function::FontStyle

Inherits:
BinaryFunction show all
Defined in:
lib/plurimath/math/function/font_style.rb

Constant Summary collapse

FONT_TYPES =
{
  mathfrak: "fraktur",
  mathcal: "script",
  mathbb: "double-struck",
  mathsf: "sans-serif",
  mathtt: "monospace",
  mathbf: "bold",
  bbb: "double-struck",
  bb: "bold",
  fr: "fraktur",
  cc: "script",
  sf: "sans-serif",
  tt: "monospace",
}.freeze

Instance Attribute Summary

Attributes inherited from BinaryFunction

#parameter_one, #parameter_two

Instance Method Summary collapse

Methods inherited from BinaryFunction

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

Constructor Details

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

Instance Method Details

#to_asciimathObject



24
25
26
27
28
29
30
# File 'lib/plurimath/math/function/font_style.rb', line 24

def to_asciimath
  if Asciimath::Constants::FONT_STYLES.include?(parameter_two.to_sym)
    "#{parameter_two}(#{parameter_one.to_asciimath})"
  else
    parameter_one.to_asciimath
  end
end

#to_latexObject



38
39
40
41
# File 'lib/plurimath/math/function/font_style.rb', line 38

def to_latex
  first_value = parameter_one.to_latex if parameter_one
  "\\#{parameter_two}{#{first_value}}"
end

#to_mathml_without_math_tagObject



32
33
34
35
36
# File 'lib/plurimath/math/function/font_style.rb', line 32

def to_mathml_without_math_tag
  type = FONT_TYPES[parameter_two.to_sym]
  first_value = parameter_one.to_mathml_without_math_tag
  "<mstyle mathvariant='#{type}'>#{first_value}</mstyle>"
end