Class: Plurimath::Math::Function::Tr

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

Instance Attribute Summary

Attributes inherited from UnaryFunction

#parameter_one

Instance Method Summary collapse

Methods inherited from UnaryFunction

#==, #class_name, #initialize

Methods inherited from Core

#class_name, #empty_tag, #insert_t_tag, #nary_attr_value, #omml_parameter, #tag_name, #validate_function_formula

Constructor Details

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

Instance Method Details

#to_asciimathObject



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

def to_asciimath
  "[#{parameter_one.map(&:to_asciimath).join(', ')}]"
end

#to_htmlObject



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

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

#to_latexObject



23
24
25
26
27
# File 'lib/plurimath/math/function/tr.rb', line 23

def to_latex
  parameter_one.reject do |td|
    td if Utility.symbol_value(td, "|") || Utility.symbol_value(td.parameter_one.first, "|")
  end.map(&:to_latex).join(" & ")
end

#to_mathml_without_math_tagObject



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

def to_mathml_without_math_tag
  first_value = parameter_one.dup
  row_lines = first_value.first.parameter_one
  row_lines.shift if Utility.symbol_value(row_lines.first, "&#x23af;")
  Utility.update_nodes(
    Utility.ox_element("mtr"),
    first_value.map(&:to_mathml_without_math_tag).compact,
  )
end

#to_omml_without_math_tagObject



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/plurimath/math/function/tr.rb', line 34

def to_omml_without_math_tag
  omml_content = parameter_one&.map(&:to_omml_without_math_tag)
  if parameter_one.count.eql?(1)
    omml_content
  else
    mr = Utility.ox_element("mr", namespace: "m")
    Utility.update_nodes(
      mr,
      omml_content,
    )
    [mr]
  end
end