Class: Plurimath::Math::Function::Table

Inherits:
TernaryFunction show all
Defined in:
lib/plurimath/math/function/table.rb

Instance Attribute Summary

Attributes inherited from TernaryFunction

#parameter_one, #parameter_three, #parameter_two

Instance Method Summary collapse

Methods inherited from TernaryFunction

#==, #class_name, #initialize

Constructor Details

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

Instance Method Details

#latex_environmentObject



35
36
37
38
# File 'lib/plurimath/math/function/table.rb', line 35

def latex_environment
  matrices_hash = Latex::Constants::ENVIRONMENTS
  matrices_hash.invert[parameter_two] if matrices_hash.value?(parameter_two)
end

#to_asciimathObject



9
10
11
12
13
14
# File 'lib/plurimath/math/function/table.rb', line 9

def to_asciimath
  first_value  = parameter_one.map(&:to_asciimath).join(",")
  second_value = parameter_two.nil? ? "[" : parameter_two
  third_value  = parameter_three.nil? ? "]" : parameter_three
  "#{second_value}#{first_value}#{third_value}"
end

#to_latexObject



28
29
30
31
32
33
# File 'lib/plurimath/math/function/table.rb', line 28

def to_latex
  first_value = parameter_one&.map(&:to_latex)&.join("\\\\")
  environment = latex_environment
  divider     = "{#{parameter_three&.map(&:to_latex).join}}" if environment == "array"
  "\\begin{#{environment}}#{divider}#{first_value}\\end{#{environment}}"
end

#to_mathml_without_math_tagObject



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/plurimath/math/function/table.rb', line 16

def to_mathml_without_math_tag
  table_value = parameter_one.map(&:to_mathml_without_math_tag).join
  if Latex::Constants::PARENTHESIS.key?(parameter_two) || parameter_two == "|"
    "<mfenced open='#{parameter_two}' close='#{parameter_three}'>"\
      "<mtable>#{table_value}</mtable></mfenced>"
  elsif parameter_two == "norm["
    "<mo>&#x2225;</mo>#{table_value}<mo>&#x2225;</mo>"
  else
    "<mtable>#{table_value}</mtable>"
  end
end