Sha256: 39eb141628c98576d9f0e70667c46593a3f261444a7be17624ccae979733a342

Contents?: true

Size: 1.18 KB

Versions: 4

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

require_relative "unary_function"

module Plurimath
  module Math
    module Function
      class Abs < UnaryFunction
        def to_mathml_without_math_tag
          symbol = Utility.ox_element("mo") << "|"
          first_value = mathml_value&.insert(0, symbol)
          Utility.update_nodes(
            Utility.ox_element("mrow"),
            first_value << symbol,
          )
        end

        def to_omml_without_math_tag
          md = (Utility.ox_element("d", namespace: "m") << mdpr_tag)
          me = Utility.ox_element("e", namespace: "m")
          Utility.update_nodes(me, omml_value)
          Utility.update_nodes(md, Array(me))
          [md]
        end

        protected

        def mdpr_tag
          attribute = { "m:val": "|" }
          mdpr = Utility.pr_element("d", namespace: "m")
          mdpr << Utility.ox_element("begChr", namespace: "m", attributes: attribute)
          mdpr << Utility.ox_element("endChr", namespace: "m", attributes: attribute)
          mdpr << Utility.ox_element("sepChr", namespace: "m", attributes: { "m:val": "" })
          mdpr << Utility.ox_element("grow", namespace: "m")
        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/abs.rb
plurimath-0.3.8 lib/plurimath/math/function/abs.rb
plurimath-0.3.7 lib/plurimath/math/function/abs.rb
plurimath-0.3.6 lib/plurimath/math/function/abs.rb