Sha256: ccd655087a82c026f2e01c4318214f533cdebf2d98540e4b21e48e10122344d0

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

require_relative "../table"

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

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

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

          def to_mathml_without_math_tag(intent)
            matrix = super
            matrix["intent"] = intent_attr_value(intent) if intent
            matrix
          end

          private

          def matrix_symbol
            capital_vmatrix? ? "⒩" : "⒱"
          end

          def capital_vmatrix?
            open_paren&.class_name == "norm"
          end

          def intent_attr_value(intent)
            capital_vmatrix? ? ":normed-matrix" : ":determinant"
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
plurimath-0.8.14 lib/plurimath/math/function/table/vmatrix.rb
plurimath-0.8.13 lib/plurimath/math/function/table/vmatrix.rb
plurimath-0.8.12 lib/plurimath/math/function/table/vmatrix.rb
plurimath-0.8.11 lib/plurimath/math/function/table/vmatrix.rb