Sha256: 31a2b51990195249e18469fe4b49498793e83f427c05af63173a2aad05b7613a

Contents?: true

Size: 1.35 KB

Versions: 4

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true

require_relative "unary_function"

module Plurimath
  module Math
    module Function
      class Tr < UnaryFunction
        def to_asciimath
          "[#{parameter_one.map(&:to_asciimath).join(', ')}]"
        end

        def to_mathml_without_math_tag
          first_value = parameter_one.dup
          row_lines = first_value.first.parameter_one
          row_lines.shift if Utility.symbol_value(row_lines.first, "&#x23af;")
          Utility.update_nodes(
            Utility.ox_element("mtr"),
            first_value.map(&:to_mathml_without_math_tag).compact,
          )
        end

        def to_latex
          parameter_one.reject do |td|
            td if Utility.symbol_value(td, "|") || Utility.symbol_value(td.parameter_one.first, "|")
          end.map(&:to_latex).join(" & ")
        end

        def to_html
          first_value = parameter_one.map(&:to_html).join
          "<tr>#{first_value}</tr>"
        end

        def to_omml_without_math_tag
          omml_content = parameter_one&.map(&:to_omml_without_math_tag)
          if parameter_one.count.eql?(1)
            omml_content
          else
            mr = Utility.ox_element("mr", namespace: "m")
            Utility.update_nodes(
              mr,
              omml_content,
            )
            [mr]
          end
        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/tr.rb
plurimath-0.3.8 lib/plurimath/math/function/tr.rb
plurimath-0.3.7 lib/plurimath/math/function/tr.rb
plurimath-0.3.6 lib/plurimath/math/function/tr.rb