Sha256: e4e59c65453898a2157769e561d8a9d3fde0859ab20f67d51d28cbc1db9ce680

Contents?: true

Size: 1.63 KB

Versions: 3

Compression:

Stored size: 1.63 KB

Contents

# frozen_string_literal: true

require_relative "ternary_function"

module Plurimath
  module Math
    module Function
      class Limits < TernaryFunction
        FUNCTION = {
          name: "function apply",
          first_value: "base",
          second_value: "subscript",
          third_value: "supscript",
        }.freeze

        def to_mathml_without_math_tag
          underover = Utility.ox_element("munderover")
          value_array = [
            validate_mathml_fields(parameter_one),
            validate_mathml_fields(parameter_two),
            validate_mathml_fields(parameter_three),
          ]
          Utility.update_nodes(underover, value_array)
        end

        def to_latex
          first_value  = parameter_one&.to_latex
          second_value = "{#{parameter_two.to_latex}}" if parameter_two
          third_value  = "{#{parameter_three.to_latex}}" if parameter_three
          "#{first_value}\\#{class_name}_#{second_value}^#{third_value}"
        end

        def to_omml_without_math_tag(display_style)
          underover(display_style)
        end

        def line_breaking(obj)
          parameter_one&.line_breaking(obj)
          if obj.value_exist?
            obj.update(self.class.new(Utility.filter_values(obj.value), parameter_two, parameter_three))
            self.parameter_two = nil
            self.parameter_three = nil
            return
          end

          parameter_two&.line_breaking(obj)
          if obj.value_exist?
            obj.update(self.class.new(nil, Utility.filter_values(obj.value), parameter_three))
            self.parameter_three = nil
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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