Sha256: f7f347e282f1ab0fdc61511a07d5716f7c7b6308c949e91a3b1258d37b9e7c8e

Contents?: true

Size: 1.48 KB

Versions: 4

Compression:

Stored size: 1.48 KB

Contents

# frozen_string_literal: true

require_relative "binary_function"

module Plurimath
  module Math
    module Function
      class Frac < BinaryFunction
        def to_asciimath
          first_value = "(#{parameter_one&.to_asciimath})" if parameter_one
          second_value = "(#{parameter_two&.to_asciimath})" if parameter_two
          "frac#{first_value}#{second_value}"
        end

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

        def to_latex
          first_value = parameter_one&.to_latex
          two_value = parameter_two&.to_latex
          "\\frac{#{first_value}}{#{two_value}}"
        end

        def to_omml_without_math_tag
          f_element   = Utility.ox_element("f", namespace: "m")
          fpr_element = Utility.ox_element("fPr", namespace: "m")
          fpr_element << Utility.pr_element("ctrl", true, namespace: "m")
          Utility.update_nodes(
            f_element,
            [
              fpr_element,
              omml_parameter(parameter_one, tag_name: "num"),
              omml_parameter(parameter_two, tag_name: "den"),
            ],
          )
          [f_element]
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
plurimath-0.3.9 lib/plurimath/math/function/frac.rb
plurimath-0.3.8 lib/plurimath/math/function/frac.rb
plurimath-0.3.7 lib/plurimath/math/function/frac.rb
plurimath-0.3.6 lib/plurimath/math/function/frac.rb