Sha256: 4301ad43dbd15588823ba1f10312969b7685252706f297887bdcb046ec79908b

Contents?: true

Size: 1.26 KB

Versions: 7

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

require_relative "../table"

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

          def to_latex
            "\\begin#{opening}#{latex_content}\\end#{matrix_class}"
          end

          def to_mathml_without_math_tag
            table_tag = Utility.ox_element("mtable", attributes: table_attribute)
            Utility.update_nodes(
              table_tag,
              value&.map(&:to_mathml_without_math_tag),
            )
            Utility.update_nodes(
              Utility.ox_element("mrow"),
              [
                mo_element(mathml_parenthesis(open_paren)),
                table_tag,
                mo_element(mathml_parenthesis(close_paren)),
              ],
            )
          end

          def to_unicodemath
            "#{matrix_symbol}(#{value.map(&:to_unicodemath).join("@")})"
          end

          private

          def matrix_symbol
            open_paren.is_a?(Math::Symbols::Paren::Lcurly) ? "Ⓢ" : "ⓢ"
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
plurimath-0.8.10 lib/plurimath/math/function/table/bmatrix.rb
plurimath-0.8.9 lib/plurimath/math/function/table/bmatrix.rb
plurimath-0.8.8 lib/plurimath/math/function/table/bmatrix.rb
plurimath-0.8.7 lib/plurimath/math/function/table/bmatrix.rb
plurimath-0.8.6 lib/plurimath/math/function/table/bmatrix.rb
plurimath-0.8.5 lib/plurimath/math/function/table/bmatrix.rb
plurimath-0.8.4 lib/plurimath/math/function/table/bmatrix.rb