Class: Plurimath::Math::Function::PowerBase

Inherits:
TernaryFunction show all
Defined in:
lib/plurimath/math/function/power_base.rb

Instance Attribute Summary

Attributes inherited from TernaryFunction

#parameter_one, #parameter_three, #parameter_two

Instance Method Summary collapse

Methods inherited from TernaryFunction

#==, #class_name, #initialize, #to_asciimath

Constructor Details

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

Instance Method Details

#omml_nary_tagObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/plurimath/math/function/power_base.rb', line 36

def omml_nary_tag
  narypr = Utility.ox_element("naryPr", namespace: "m")
  chr_value(narypr)
  narypr << Utility.ox_element(
    "limLoc",
    namespace: "m",
    attributes: { "m:val": "subSup" },
  )
  hide_tags(narypr)
  narypr << Utility.pr_element("ctrl", true, namespace: "m")
  [
    narypr,
    sub_element,
    sup_element,
  ]
end

#to_htmlObject



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

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

#to_latexObject



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

def to_latex
  first_value  = parameter_one.to_latex if parameter_one
  second_value = parameter_two.to_latex if parameter_two
  third_value  = parameter_three.to_latex if parameter_three
  "#{first_value}_{#{second_value}}^{#{third_value}}"
end

#to_mathml_without_math_tagObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/plurimath/math/function/power_base.rb', line 9

def to_mathml_without_math_tag
  tag_name = (["ubrace", "obrace"].include?(parameter_one&.class_name) ? "underover" : "subsup")
  subsup_tag = Utility.ox_element("m#{tag_name}")
  new_arr = []
  new_arr << parameter_one.to_mathml_without_math_tag
  new_arr << parameter_two&.to_mathml_without_math_tag
  new_arr << parameter_three&.to_mathml_without_math_tag
  Utility.update_nodes(
    subsup_tag,
    new_arr,
  )
end

#to_omml_without_math_tagObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/plurimath/math/function/power_base.rb', line 53

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_element,
      sub_element,
      sup_element,
    ],
  )
end