Sha256: b4c16d72430d12778fdeec586015bdb7c5f78bca5c7676b9eb5461a3edff72cf

Contents?: true

Size: 1.42 KB

Versions: 2

Compression:

Stored size: 1.42 KB

Contents

# frozen_string_literal: true

require_relative "binary_function"

module Plurimath
  module Math
    module Function
      class Root < BinaryFunction
        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

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
plurimath-0.3.7 lib/plurimath/math/function/root.rb
plurimath-0.3.6 lib/plurimath/math/function/root.rb