Class: Plurimath::Math::Function::Table
- Inherits:
-
Core
- Object
- Core
- Plurimath::Math::Function::Table
show all
- Defined in:
- lib/plurimath/math/function/table.rb,
lib/plurimath/math/function/table/align.rb,
lib/plurimath/math/function/table/array.rb,
lib/plurimath/math/function/table/cases.rb,
lib/plurimath/math/function/table/split.rb,
lib/plurimath/math/function/table/matrix.rb,
lib/plurimath/math/function/table/bmatrix.rb,
lib/plurimath/math/function/table/eqarray.rb,
lib/plurimath/math/function/table/pmatrix.rb,
lib/plurimath/math/function/table/vmatrix.rb,
lib/plurimath/math/function/table/multline.rb
Defined Under Namespace
Classes: Align, Array, Bmatrix, Cases, Eqarray, Matrix, Multline, Pmatrix, Split, Vmatrix
Constant Summary
collapse
- SIMPLE_TABLES =
%w[array align split].freeze
Constants inherited
from Core
Core::REPLACABLES
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#==(object) ⇒ Object
-
#initialize(value = nil, open_paren = nil, close_paren = nil, options = {}) ⇒ Table
constructor
-
#to_asciimath ⇒ Object
-
#to_asciimath_math_zone(spacing, last = false, indent = true) ⇒ Object
-
#to_html ⇒ Object
-
#to_latex ⇒ Object
-
#to_latex_math_zone(spacing, last = false, indent = true) ⇒ Object
-
#to_mathml_math_zone(spacing, last = false, indent = true) ⇒ Object
-
#to_mathml_without_math_tag ⇒ Object
-
#to_omml_math_zone(spacing, last = false, indent = true, display_style:) ⇒ Object
-
#to_omml_without_math_tag(display_style) ⇒ Object
-
#to_unicodemath ⇒ Object
Methods inherited from Core
#ascii_fields_to_print, #class_name, #cloned_objects, #common_math_zone_conversion, #dump_mathml, #dump_nodes, #dump_omml, #dump_ox_nodes, #empty_tag, #extract_class_name_from_text, #extractable?, #filtered_values, #font_style_t_tag, #get, #gsub_spacing, #insert_t_tag, #invert_unicode_symbols, #is_binary_function?, #is_nary_function?, #is_nary_symbol?, #is_ternary_function?, #is_unary?, #latex_fields_to_print, #line_breaking, #linebreak, #mathml_fields_to_print, #mini_sized?, #nary_attr_value, #omml_fields_to_print, #omml_nodes, #omml_parameter, #omml_tag_name, #ox_element, #prime_unicode?, #r_element, #replacable_values, #result, #separate_table, #set, #tag_name, #unicodemath_parens, #updated_object_values, #validate_function_formula, #validate_mathml_fields, #variable_value, #variables
Constructor Details
#initialize(value = nil, open_paren = nil, close_paren = nil, options = {}) ⇒ Table
Returns a new instance of Table.
11
12
13
14
15
16
17
18
19
|
# File 'lib/plurimath/math/function/table.rb', line 11
def initialize(value = nil,
open_paren = nil,
close_paren = nil,
options = {})
@value = value
@open_paren = Utility.symbols_class(open_paren, lang: :unicodemath)
@close_paren = Utility.symbols_class(close_paren, lang: :unicodemath)
@options = options
end
|
Instance Attribute Details
#close_paren ⇒ Object
Returns the value of attribute close_paren.
7
8
9
|
# File 'lib/plurimath/math/function/table.rb', line 7
def close_paren
@close_paren
end
|
#open_paren ⇒ Object
Returns the value of attribute open_paren.
7
8
9
|
# File 'lib/plurimath/math/function/table.rb', line 7
def open_paren
@open_paren
end
|
#options ⇒ Object
Returns the value of attribute options.
7
8
9
|
# File 'lib/plurimath/math/function/table.rb', line 7
def options
@options
end
|
#value ⇒ Object
Returns the value of attribute value.
7
8
9
|
# File 'lib/plurimath/math/function/table.rb', line 7
def value
@value
end
|
Instance Method Details
#==(object) ⇒ Object
21
22
23
24
25
26
27
|
# File 'lib/plurimath/math/function/table.rb', line 21
def ==(object)
object.class == self.class &&
object.value == value &&
object.options == options &&
object.open_paren == open_paren &&
object.close_paren == close_paren
end
|
#to_asciimath ⇒ Object
29
30
31
32
33
34
35
36
37
|
# File 'lib/plurimath/math/function/table.rb', line 29
def to_asciimath
return parentheless_table if SIMPLE_TABLES.include?(class_name)
parenthesis = Asciimath::Constants::TABLE_PARENTHESIS
first_value = value.map(&:to_asciimath).join(", ")
lparen = open_paren.nil? ? "[" : open_paren.to_asciimath
rparen = close_paren.nil? ? parenthesis[lparen.to_sym] : close_paren.to_asciimath
"#{lparen}#{first_value}#{rparen}"
end
|
#to_asciimath_math_zone(spacing, last = false, indent = true) ⇒ Object
90
91
92
93
94
95
|
# File 'lib/plurimath/math/function/table.rb', line 90
def to_asciimath_math_zone(spacing, last = false, indent = true)
[
"#{spacing}\"table\" function apply\n",
Formula.new(value).to_asciimath_math_zone(gsub_spacing(spacing, last), last, indent),
]
end
|
#to_html ⇒ Object
68
69
70
71
|
# File 'lib/plurimath/math/function/table.rb', line 68
def to_html
first_value = value.map(&:to_html).join
"<table>#{first_value}</table>"
end
|
#to_latex ⇒ Object
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/plurimath/math/function/table.rb', line 57
def to_latex
return "\\begin{Vmatrix}#{latex_content}\\end{Vmatrix}" if open_paren.is_a?(Math::Symbols::Paren::Norm)
separator = "{#{table_attribute(:latex)}}" if environment&.include?("array")
left_paren = open_paren&.to_latex || "."
right_paren = close_paren&.to_latex || "."
left = "\\left #{left_paren}\\begin{matrix}"
right = "\\end{matrix}\\right #{right_paren.delete_prefix("\\right")}"
"#{left}#{separator}#{latex_content}#{right}"
end
|
#to_latex_math_zone(spacing, last = false, indent = true) ⇒ Object
97
98
99
100
101
102
|
# File 'lib/plurimath/math/function/table.rb', line 97
def to_latex_math_zone(spacing, last = false, indent = true)
[
"#{spacing}\"table\" function apply\n",
Formula.new(value).to_latex_math_zone(gsub_spacing(spacing, last), last, indent),
]
end
|
#to_mathml_math_zone(spacing, last = false, indent = true) ⇒ Object
104
105
106
107
108
109
|
# File 'lib/plurimath/math/function/table.rb', line 104
def to_mathml_math_zone(spacing, last = false, indent = true)
[
"#{spacing}\"table\" function apply\n",
Formula.new(value).to_mathml_math_zone(gsub_spacing(spacing, last), last, indent),
]
end
|
#to_mathml_without_math_tag ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/plurimath/math/function/table.rb', line 39
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),
)
return norm_table(table_tag) if open_paren.is_a?(Math::Symbols::Paren::Norm)
if mathml_paren_present?(open_paren) || mathml_paren_present?(close_paren)
first_paren = mo_element(mathml_parenthesis(open_paren))
second_paren = mo_element(mathml_parenthesis(close_paren))
mrow_tag = Utility.ox_element("mrow")
return Utility.update_nodes(mrow_tag, [first_paren, table_tag, second_paren])
end
table_tag
end
|
#to_omml_math_zone(spacing, last = false, indent = true, display_style:) ⇒ Object
111
112
113
114
115
116
|
# File 'lib/plurimath/math/function/table.rb', line 111
def to_omml_math_zone(spacing, last = false, indent = true, display_style:)
[
"#{spacing}\"table\" function apply\n",
Formula.new(value).to_omml_math_zone(gsub_spacing(spacing, last), last, indent, display_style: display_style),
]
end
|
#to_omml_without_math_tag(display_style) ⇒ Object
73
74
75
76
77
78
79
80
|
# File 'lib/plurimath/math/function/table.rb', line 73
def to_omml_without_math_tag(display_style)
ox_table = if single_table?
single_td_table(display_style)
else
multiple_td_table(display_style)
end
fenced_table(ox_table)
end
|
#to_unicodemath ⇒ Object
82
83
84
85
86
87
88
|
# File 'lib/plurimath/math/function/table.rb', line 82
def to_unicodemath
if unicodemath_table_class?
"#{unicodemath_class_name}(#{value.map(&:to_unicodemath).join("@")})"
else
"#{open_paren&.to_unicodemath}■(#{value.map(&:to_unicodemath).join("@")})#{close_paren&.to_unicodemath}"
end
end
|