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

Inherits:
TernaryFunction show all
Defined in:
lib/plurimath/math/function/table.rb,
lib/plurimath/math/function/table/align.rb,
lib/plurimath/math/function/table/array.rb,
lib/plurimath/math/function/table/split.rb,
lib/plurimath/math/function/table/matrix.rb,
lib/plurimath/math/function/table/bmatrix.rb,
lib/plurimath/math/function/table/pmatrix.rb,
lib/plurimath/math/function/table/vmatrix.rb,
lib/plurimath/math/function/table/multline.rb

Direct Known Subclasses

Align, Array, Bmatrix, Matrix, Multline, Pmatrix, Split, Vmatrix

Defined Under Namespace

Classes: Align, Array, Bmatrix, Matrix, Multline, Pmatrix, Split, Vmatrix

Instance Attribute Summary

Attributes inherited from TernaryFunction

#parameter_one, #parameter_three, #parameter_two

Instance Method Summary collapse

Methods inherited from TernaryFunction

#==, #class_name

Constructor Details

#initialize(parameter_one = nil, parameter_two = nil, parameter_three = nil) ⇒ Table

Returns a new instance of Table.



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

def initialize(parameter_one = nil,
               parameter_two = nil,
               parameter_three = nil)
  super
end

Instance Method Details

#latex_environmentObject



41
42
43
44
45
# File 'lib/plurimath/math/function/table.rb', line 41

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

#to_asciimathObject



15
16
17
18
19
20
# File 'lib/plurimath/math/function/table.rb', line 15

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_htmlObject



47
48
49
50
# File 'lib/plurimath/math/function/table.rb', line 47

def to_html
  first_value = parameter_one.map(&:to_html).join
  "<table>#{first_value}</table>"
end

#to_latexObject



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

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

#to_mathml_without_math_tagObject



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/plurimath/math/function/table.rb', line 22

def to_mathml_without_math_tag
  table_value = parameter_one.map(&:to_mathml_without_math_tag).join
  parenthesis = Latex::Constants::PARENTHESIS
  if 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