Sha256: 189b6e02b25865535866d0976cdb187b690d7ad4f5788b8f9778adb6ac1eca08

Contents?: true

Size: 1.23 KB

Versions: 3

Compression:

Stored size: 1.23 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 == "{" ? "Ⓢ" : "ⓢ"
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
plurimath-0.8.2 lib/plurimath/math/function/table/bmatrix.rb
plurimath-0.8.1 lib/plurimath/math/function/table/bmatrix.rb
plurimath-0.8.0 lib/plurimath/math/function/table/bmatrix.rb