Class: Plurimath::Math::Function::Table
Instance Attribute Summary
#parameter_one, #parameter_three, #parameter_two
Instance Method Summary
collapse
#==, #class_name, #initialize
Instance Method Details
#latex_environment ⇒ Object
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_asciimath ⇒ Object
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_latex ⇒ Object
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_tag ⇒ Object
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>∥</mo>#{table_value}<mo>∥</mo>"
else
"<mtable>#{table_value}</mtable>"
end
end
|