Class: Plurimath::Math::Function::Log

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

Instance Attribute Summary

Attributes inherited from BinaryFunction

#parameter_one, #parameter_two

Instance Method Summary collapse

Methods inherited from BinaryFunction

#==, #class_name, #initialize

Constructor Details

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

Instance Method Details

#to_asciimathObject



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

def to_asciimath
  first_value = "_#{wrapped(parameter_one)}" if parameter_one
  second_value = "^#{wrapped(parameter_two)}" if parameter_two
  "log#{first_value}#{second_value}"
end

#to_htmlObject



21
22
23
24
25
# File 'lib/plurimath/math/function/log.rb', line 21

def to_html
  first_value = "<sub>#{parameter_one.to_html}</sub>" if parameter_one
  second_value = "<sup>#{parameter_two.to_html}</sup>" if parameter_two
  "<i>log</i>#{first_value}#{second_value}"
end

#to_latexObject



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

def to_latex
  first_value = "_#{latex_wrapped(parameter_one)}" if parameter_one
  second_value = "^#{latex_wrapped(parameter_two)}" if parameter_two
  "\\log#{first_value}#{second_value}"
end

#to_mathml_without_math_tagObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/plurimath/math/function/log.rb', line 46

def to_mathml_without_math_tag
  subsup_tag = Utility.ox_element("msubsup")
  first_value = (Utility.ox_element("mi") << "log")
  if parameter_one || parameter_two
    new_arr = [first_value]
    new_arr << parameter_one&.to_mathml_without_math_tag
    new_arr << parameter_two&.to_mathml_without_math_tag
    Utility.update_nodes(
      subsup_tag,
      new_arr,
    )
  else
    first_value
  end
end

#to_omml_without_math_tagObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/plurimath/math/function/log.rb', line 27

def to_omml_without_math_tag
  func   = Utility.ox_element("func", namespace: "m")
  funcpr = Utility.ox_element("funcPr", namespace: "m")
  funcpr << Utility.pr_element("ctrl", true, namespace: "m")
  fname  = Utility.ox_element("fName", namespace: "m")
  mr     = Utility.ox_element("r", namespace: "m")
  rpr    = Utility.rpr_element
  mt     = Utility.ox_element("t", namespace: "m") << class_name
  fname << Utility.update_nodes(mr, [rpr, mt])
  log_values = [first_value, second_value].flatten.compact
  Utility.update_nodes(
    func,
    [
      funcpr,
      fname,
    ] + log_values,
  )
end