Sha256: 7d7fb46af309439f5db0cf3760256b2cf435f585ee0c3b700ae7fa1278507607

Contents?: true

Size: 1.37 KB

Versions: 4

Compression:

Stored size: 1.37 KB

Contents

# frozen_string_literal: true

require_relative "binary_function"

module Plurimath
  module Math
    module Function
      class Root < BinaryFunction
        FUNCTION = {
          name: "root",
          first_value: "radicand",
          second_value: "index",
        }.freeze

        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(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
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
plurimath-0.7.2 lib/plurimath/math/function/root.rb
plurimath-0.7.1 lib/plurimath/math/function/root.rb
plurimath-0.7.0 lib/plurimath/math/function/root.rb
plurimath-0.6.0 lib/plurimath/math/function/root.rb