Sha256: 06a5cbeafe41f67160838fec18611a5d450e3f296fc04f26c76393dfb38f7fff

Contents?: true

Size: 1.74 KB

Versions: 14

Compression:

Stored size: 1.74 KB

Contents

# frozen_string_literal: true

require_relative "../table"

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

          def to_asciimath(options:)
            ascii_value = value.map { |v| v.to_asciimath(options: options) }.join(", ")
            "{:#{ascii_value}:}"
          end

          def to_latex(options:)
            "\\begin#{opening}#{latex_content(options: options)}\\end#{matrix_class}"
          end

          def to_mathml_without_math_tag(intent, options:)
            table_tag = Utility.update_nodes(
              ox_element("mtable", attributes: table_attribute),
              value&.map { |object| object&.to_mathml_without_math_tag(intent, options: options) }
            )
            return table_tag if table_tag_only?

            Utility.update_nodes(
              ox_element("mrow"),
              [mo_tag(open_paren), table_tag, mo_tag(close_paren)]
            )
          end

          def to_unicodemath(options:)
            first_value = value.map { |v| v.to_unicodemath(options: options) }.join("@")
            "#{open_paren&.to_unicodemath(options: options)}■(#{first_value})#{close_paren&.to_unicodemath(options: options)}"
          end

          protected

          def mo_tag(paren)
            (ox_element("mo") << paren) unless validate_paren(paren)
          end

          def table_tag_only?
            (open_paren&.class_name == "lround" && close_paren&.class_name == "rround") ||
              !(open_paren && close_paren)
          end
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
plurimath-0.9.0 lib/plurimath/math/function/table/matrix.rb
plurimath-0.8.27 lib/plurimath/math/function/table/matrix.rb
plurimath-0.8.26 lib/plurimath/math/function/table/matrix.rb
plurimath-0.8.25 lib/plurimath/math/function/table/matrix.rb
plurimath-0.8.24 lib/plurimath/math/function/table/matrix.rb
plurimath-0.8.23 lib/plurimath/math/function/table/matrix.rb
plurimath-0.8.22 lib/plurimath/math/function/table/matrix.rb
plurimath-0.8.21 lib/plurimath/math/function/table/matrix.rb
plurimath-0.8.20 lib/plurimath/math/function/table/matrix.rb
plurimath-0.8.19 lib/plurimath/math/function/table/matrix.rb
plurimath-0.8.18 lib/plurimath/math/function/table/matrix.rb
plurimath-0.8.17 lib/plurimath/math/function/table/matrix.rb
plurimath-0.8.16 lib/plurimath/math/function/table/matrix.rb
plurimath-0.8.15 lib/plurimath/math/function/table/matrix.rb