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

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::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



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

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
# File 'lib/plurimath/math/function/log.rb', line 27

def to_omml_without_math_tag
  ssubsup   = Utility.ox_element("sSubSup", namespace: "m")
  ssubsuppr = Utility.ox_element("sSubSupPr", namespace: "m")
  ssubsuppr << hide_tags(
    Utility.pr_element("ctrl", true, namespace: "m"),
  )
  Utility.update_nodes(
    ssubsup,
    [
      ssubsuppr,
      e_parameter,
      omml_parameter(parameter_one, tag_name: "sub"),
      omml_parameter(parameter_two, tag_name: "sup"),
    ],
  )
  [ssubsup]
end