Sha256: 256039ca73382c504f0811a0b3f2b6829418eb7e54366a64ab4cb0018075e4d2

Contents?: true

Size: 1.42 KB

Versions: 8

Compression:

Stored size: 1.42 KB

Contents

# frozen_string_literal: true

require_relative "../table"

module Plurimath
  module Math
    module Function
      class Table
        class Array < Table
          def initialize(value = [],
                         open_paren = "[",
                         close_paren = "]",
                         options = {})
            super
          end

          def to_latex(options:)
            "\\begin{array}#{array_args || '.'}#{latex_content(options: options)}\\end{array}"
          end

          def to_mathml_without_math_tag(intent, options:)
            Utility.update_nodes(
              ox_element("mtable", attributes: attributes(intent)),
              value&.map { |object| object&.to_mathml_without_math_tag(intent, options: options) },
            )
          end

          private

          def array_args
            args = []
            value.first.parameter_one.each do |td|
              args << if Utility.symbol_value(td.parameter_one.first, "|")
                        "|"
                      else
                        Utility::ALIGNMENT_LETTERS.invert[Hash(td.parameter_two)[:columnalign]]&.to_s
                      end
            end
            "{#{args.join}}" unless args.compact.empty?
          end

          def attributes(intent)
            return table_attribute unless intent

            table_attribute.merge(intent: intent_names[:equations])
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
plurimath-0.8.24 lib/plurimath/math/function/table/array.rb
plurimath-0.8.23 lib/plurimath/math/function/table/array.rb
plurimath-0.8.22 lib/plurimath/math/function/table/array.rb
plurimath-0.8.21 lib/plurimath/math/function/table/array.rb
plurimath-0.8.20 lib/plurimath/math/function/table/array.rb
plurimath-0.8.19 lib/plurimath/math/function/table/array.rb
plurimath-0.8.18 lib/plurimath/math/function/table/array.rb
plurimath-0.8.17 lib/plurimath/math/function/table/array.rb