Sha256: 5fca13827ec2f0b2b430e10c8f7670ce95a3942e608e7b91be9aea2f8077f624

Contents?: true

Size: 1.11 KB

Versions: 17

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

require_relative "binary_function"

module Plurimath
  module Math
    module Function
      class Stackrel < BinaryFunction
        def to_asciimath
          first_value  = wrapped(parameter_one)
          second_value = wrapped(parameter_two)
          "#{class_name}#{first_value}#{second_value}"
        end

        def to_mathml_without_math_tag
          mover = Utility.ox_element("mover")
          first_value = Utility.ox_element("mrow")
          first_value << parameter_one.to_mathml_without_math_tag if parameter_one
          second_value = Utility.ox_element("mrow")
          second_value << parameter_two.to_mathml_without_math_tag if parameter_two
          Utility.update_nodes(mover, [second_value, first_value])
        end

        def to_html
          first_value = parameter_one&.to_html
          second_value = parameter_two&.to_html
          "#{first_value}#{second_value}"
        end

        protected

        def wrapped(field)
          string = field&.to_asciimath || ""
          string.start_with?("(") ? string : "(#{string})"
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
plurimath-0.3.7 lib/plurimath/math/function/stackrel.rb
plurimath-0.3.6 lib/plurimath/math/function/stackrel.rb
plurimath-0.3.5 lib/plurimath/math/function/stackrel.rb
plurimath-0.3.4 lib/plurimath/math/function/stackrel.rb
plurimath-0.3.3 lib/plurimath/math/function/stackrel.rb
plurimath-0.3.2 lib/plurimath/math/function/stackrel.rb
plurimath-0.3.1.2 lib/plurimath/math/function/stackrel.rb
plurimath-0.3.1 lib/plurimath/math/function/stackrel.rb
plurimath-0.3.0 lib/plurimath/math/function/stackrel.rb
plurimath-0.2.9 lib/plurimath/math/function/stackrel.rb
plurimath-0.2.8 lib/plurimath/math/function/stackrel.rb
plurimath-0.2.7 lib/plurimath/math/function/stackrel.rb
plurimath-0.2.6 lib/plurimath/math/function/stackrel.rb
plurimath-0.2.5 lib/plurimath/math/function/stackrel.rb
plurimath-0.2.4 lib/plurimath/math/function/stackrel.rb
plurimath-0.2.3 lib/plurimath/math/function/stackrel.rb
plurimath-0.2.2 lib/plurimath/math/function/stackrel.rb