Class: Plurimath::Math::Function::Root

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

Instance Attribute Summary

Attributes inherited from BinaryFunction

#parameter_one, #parameter_two

Instance Method Summary collapse

Methods inherited from BinaryFunction

#==, #all_values_exist?, #any_value_exist?, #initialize, #to_asciimath, #to_html

Methods inherited from Core

#class_name, #empty_tag, #extract_class_from_text, #extractable?, #font_style_t_tag, #insert_t_tag, #nary_attr_value, #omml_parameter, #omml_tag_name, #r_element, #tag_name, #validate_function_formula

Constructor Details

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

Instance Method Details

#to_latexObject



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

def to_latex
  first_value = parameter_one&.to_latex
  second_value = parameter_two&.to_latex
  "\\sqrt[#{first_value}]{#{second_value}}"
end

#to_mathml_without_math_tagObject



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

def to_mathml_without_math_tag
  first_value = parameter_one&.to_mathml_without_math_tag
  second_value = parameter_two&.to_mathml_without_math_tag
  Utility.update_nodes(
    Utility.ox_element("mroot"),
    [
      second_value,
      first_value,
    ],
  )
end

#to_omml_without_math_tag(display_style) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/plurimath/math/function/root.rb', line 27

def to_omml_without_math_tag(display_style)
  rad_element = Utility.ox_element("rad", namespace: "m")
  pr_element  = Utility.ox_element("radPr", namespace: "m")
  Utility.update_nodes(
    rad_element,
    [
      (pr_element << Utility.pr_element("ctrl", true, namespace: "m")),
      omml_parameter(parameter_two, display_style, tag_name: "deg"),
      omml_parameter(parameter_one, display_style, tag_name: "e"),
    ],
  )
  [rad_element]
end