Class: Plurimath::Math::Function::Fenced
Constant Summary
Plurimath::Mathml::Utility::FormulaTransformation::CONDITIONAL_COMMON_UNARY_FUNCTIONS, Plurimath::Mathml::Utility::FormulaTransformation::SYMBOL_UPDATABLE_FUNCTIONS
Constants inherited
from Core
Core::ALL_PARAMETERS, Core::REPLACABLES
Instance Attribute Summary collapse
#temp_mathml_order
#hide_function_name, #parameter_one, #parameter_three, #parameter_two
Instance Method Summary
collapse
-
#==(object) ⇒ Object
-
#close=(value) ⇒ Object
-
#content=(value) ⇒ Object
-
#element_order=(value) ⇒ Object
-
#initialize(parameter_one = nil, parameter_two = nil, parameter_three = nil, options = {}) ⇒ Fenced
constructor
A new instance of Fenced.
-
#intent_names ⇒ Object
-
#line_breaking(obj) ⇒ Object
-
#mfenced_value=(value) ⇒ Object
-
#mfrac_value=(value) ⇒ Object
-
#mfraction_value=(value) ⇒ Object
-
#mi_value=(value) ⇒ Object
-
#mini_sized? ⇒ Boolean
-
#mini_sized_unicode(options:) ⇒ Object
-
#mmultiscripts_value=(value) ⇒ Object
-
#mn_value=(value) ⇒ Object
-
#mo_value=(value) ⇒ Object
-
#mover_value=(value) ⇒ Object
-
#mpadded_value=(value) ⇒ Object
-
#mphantom_value=(value) ⇒ Object
-
#mrow_value=(value) ⇒ Object
-
#mspace_value=(value) ⇒ Object
-
#msqrt_value=(value) ⇒ Object
-
#mstyle_value=(value) ⇒ Object
-
#msub_value=(value) ⇒ Object
-
#msubsup_value=(value) ⇒ Object
-
#msup_value=(value) ⇒ Object
-
#mtable_value=(value) ⇒ Object
-
#mtext_value=(value) ⇒ Object
-
#munder_value=(value) ⇒ Object
-
#munderover_value=(value) ⇒ Object
-
#open=(value) ⇒ Object
-
#separators=(value) ⇒ Object
-
#to_asciimath(options:) ⇒ Object
-
#to_asciimath_math_zone(spacing, last = false, indent = true, options:) ⇒ Object
-
#to_html(options:) ⇒ Object
-
#to_latex(options:) ⇒ Object
-
#to_latex_math_zone(spacing, last = false, indent = true, options:) ⇒ Object
-
#to_mathml_math_zone(spacing, last = false, indent = true, options:) ⇒ Object
-
#to_mathml_without_math_tag(intent, options:) ⇒ Object
-
#to_omml_math_zone(spacing, last = false, indent = true, display_style:, options:) ⇒ Object
-
#to_omml_without_math_tag(display_style, options:) ⇒ Object
-
#to_unicodemath(options:) ⇒ Object
-
#to_unicodemath_math_zone(spacing, last = false, indent = true, options:) ⇒ Object
#accent=, #accentunder=, #bevelled=, #clear_temp_order, #linebreak=, #linebreakstyle=, #linethickness=, #maligngroup_value=, #malignmark_value=, #mathvariant=, #menclose_value=, #merror_value=, #mglyph_value=, #mlabeledtr_value=, #mlongdiv_value=, #mroot_value=, #ms_value=, #mscarries_value=, #mscarry_value=, #msgroup_value=, #msline_value=, #msrow_value=, #mstack_value=, #none_value=, #notation=, #semantics_value=
#accent, #accentunder, #align, #align=, #alignmentscope, #alignmentscope=, #annotation, #background, #background=, #bevelled, #charalign, #charalign=, #charspacing, #charspacing=, #close, #color, #color=, #columnalign, #columnalign=, #columnlines, #columnlines=, #columnspacing, #columnspacing=, #columnspan, #columnspan=, #columnwidth, #columnwidth=, #crossout, #crossout=, #decimalpoint, #decimalpoint=, #denomalign, #denomalign=, #depth, #depth=, #dir, #dir=, #displaystyle, #displaystyle=, #edge, #edge=, #equalcolumns, #equalcolumns=, #equalrows, #equalrows=, #fence, #fence=, #fontfamily, #fontfamily=, #fontsize, #fontsize=, #fontstyle, #fontstyle=, #fontweight, #fontweight=, #form, #form=, #frame, #frame=, #framespacing, #framespacing=, #groupalign, #groupalign=, #height, #height=, #id, #indentalign, #indentalign=, #indentalignfirst, #indentalignfirst=, #indentalignlast, #indentalignlast=, #indentshift, #indentshift=, #indentshiftfirst, #indentshiftfirst=, #indentshiftlast, #indentshiftlast=, #indenttarget, #indenttarget=, #infixlinebreakstyle, #infixlinebreakstyle=, #intent, #intent=, #largeop, #largeop=, #leftoverhang, #leftoverhang=, #length, #length=, #linebreak, #linebreakmultchar, #linebreakmultchar=, #linebreakstyle, #lineleading, #lineleading=, #linethickness, #location, #location=, #longdivstyle, #longdivstyle=, #lquote, #lquote=, #lspace, #lspace=, #maligngroup_value, #malignmark, #malignmark=, #malignmark_value, #mathbackground, #mathbackground=, #mathbackgroundcolor, #mathbackgroundcolor=, #mathcolor, #mathcolor=, #mathsize, #mathsize=, #mathvariant, #maxsize, #maxsize=, #mediummathspace, #mediummathspace=, #menclose_value, #merror_value, #mfenced_value, #mfrac_value, #mfraction_value, #mglyph_value, #mi_value, #minlabelspacing, #minlabelspacing=, #minsize, #minsize=, #mlabeledtr_value, #mlongdiv_value, #mmultiscripts_value, #mn_value, #mo_value, #movablelimits, #movablelimits=, #mover_value, #mpadded_value, #mphantom_value, #mprescripts_value, #mprescripts_value=, #mroot_value, #mrow_value, #ms_value, #mscarries_value, #mscarry_value, #msgroup_value, #msline_value, #mslinethickness, #mslinethickness=, #mspace_value, #msqrt_value, #msrow_value, #mstack_value, #mstyle_value, #msub_value, #msubsup_value, #msup_value, #mtable_value, #mtd_value, #mtext_value, #mtr_value, #munder_value, #munderover_value, #none_value, #notation, #numalign, #numalign=, #open, #position, #position=, #rightoverhang, #rightoverhang=, #rowalign, #rowalign=, #rowlines, #rowlines=, #rowspacing, #rowspacing=, #rowspan, #rowspan=, #rquote, #rquote=, #rspace, #rspace=, #scriptlevel, #scriptlevel=, #scriptminsize, #scriptminsize=, #scriptsizemultiplier, #scriptsizemultiplier=, #selection, #selection=, #semantics_value, #separator, #separator=, #separators, #shift, #shift=, #side, #side=, #stackalign, #stackalign=, #stretchy, #stretchy=, #subscriptshift, #subscriptshift=, #superscriptshift, #superscriptshift=, #symmetric, #symmetric=, #thickmathspace, #thickmathspace=, #thinmathspace, #thinmathspace=, #valign, #valign=, #verythickmathspace, #verythickmathspace=, #verythinmathspace, #verythinmathspace=, #veryverythickmathspace, #veryverythickmathspace=, #veryverythinmathspace, #veryverythinmathspace=, #width, #width=
#all_values_exist?, #any_value_exist?
Methods inherited from Core
#ascii_fields_to_print, #class_name, #cloned_objects, #common_math_zone_conversion, descendants, #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, inherited, #insert_t_tag, #invert_unicode_symbols, #is_binary_function?, #is_mrow?, #is_mstyle?, #is_nary_function?, #is_nary_symbol?, #is_ternary_function?, #is_unary?, #latex_fields_to_print, #linebreak?, #mathml_fields_to_print, #nary_attr_value, #nary_intent_name, #omml_fields_to_print, #omml_nodes, #omml_parameter, #omml_tag_name, #ox_element, #paren?, #pretty_print_instance_variables, #prime_unicode?, #r_element, #replacable_values, #result, #separate_table, #set, #symbol?, #tag_name, #to_ms_value, #unicodemath_fields_to_print, #unicodemath_parens, #updated_object_values, #validate_function_formula, #validate_mathml_fields, #variable_value, #variables
Constructor Details
#initialize(parameter_one = nil, parameter_two = nil, parameter_three = nil, options = {}) ⇒ Fenced
Returns a new instance of Fenced.
14
15
16
17
18
19
20
21
|
# File 'lib/plurimath/math/function/fenced.rb', line 14
def initialize(
parameter_one = nil,
parameter_two = nil,
parameter_three = nil,
options = {})
super(parameter_one, parameter_two, parameter_three)
@options = options
end
|
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
12
13
14
|
# File 'lib/plurimath/math/function/fenced.rb', line 12
def options
@options
end
|
Instance Method Details
#==(object) ⇒ Object
23
24
25
26
|
# File 'lib/plurimath/math/function/fenced.rb', line 23
def ==(object)
super(object) &&
object.options == options
end
|
#close=(value) ⇒ Object
182
183
184
185
186
|
# File 'lib/plurimath/math/function/fenced.rb', line 182
def close=(value)
return unless value
@parameter_three = validate_symbols(value)
end
|
#content=(value) ⇒ Object
#element_order=(value) ⇒ Object
188
189
190
|
# File 'lib/plurimath/math/function/fenced.rb', line 188
def element_order=(value)
@parameter_two = validated_order(value)
end
|
#intent_names ⇒ Object
152
153
154
155
156
157
158
159
160
161
|
# File 'lib/plurimath/math/function/fenced.rb', line 152
def intent_names
{
open_closed_interval: "open-closed-interval",
closed_open_interval: "closed-open-interval",
binomial_coefficient: "binomial-coefficient",
closed_interval: "closed-interval",
open_interval: "open-interval",
fenced: ":fenced",
}
end
|
#line_breaking(obj) ⇒ Object
134
135
136
137
138
139
|
# File 'lib/plurimath/math/function/fenced.rb', line 134
def line_breaking(obj)
field_values = result(Array(parameter_two))
return unless field_values.length > 1
obj.update(value_split(obj, field_values))
end
|
#mfenced_value=(value) ⇒ Object
284
285
286
|
# File 'lib/plurimath/math/function/fenced.rb', line 284
def mfenced_value=(value)
update_temp_order(value, "mfenced")
end
|
#mfrac_value=(value) ⇒ Object
276
277
278
|
# File 'lib/plurimath/math/function/fenced.rb', line 276
def mfrac_value=(value)
update_temp_order(value, "mfrac")
end
|
#mfraction_value=(value) ⇒ Object
339
340
341
|
# File 'lib/plurimath/math/function/fenced.rb', line 339
def mfraction_value=(value)
update_temp_order(value, "mfraction")
end
|
#mi_value=(value) ⇒ Object
192
193
194
195
196
197
198
199
200
201
202
|
# File 'lib/plurimath/math/function/fenced.rb', line 192
def mi_value=(value)
return if value.nil? || value.empty?
update(
replace_order_with_value(
@parameter_two,
Array(validate_symbols(value)),
"mi"
)
)
end
|
#mini_sized? ⇒ Boolean
141
142
143
144
145
|
# File 'lib/plurimath/math/function/fenced.rb', line 141
def mini_sized?
parameter_one&.mini_sized? ||
Math::Formula.new(parameter_two)&.mini_sized? ||
parameter_three&.mini_sized?
end
|
#mini_sized_unicode(options:) ⇒ Object
147
148
149
150
|
# File 'lib/plurimath/math/function/fenced.rb', line 147
def mini_sized_unicode(options:)
fenced_value = parameter_two&.map { |param| param.to_unicodemath(options: options) }&.join
"#{parameter_one.to_unicodemath(options: options)}#{fenced_value}#{parameter_three.to_unicodemath(options: options)}"
end
|
#mmultiscripts_value=(value) ⇒ Object
343
344
345
|
# File 'lib/plurimath/math/function/fenced.rb', line 343
def mmultiscripts_value=(value)
update_temp_order(value, "mmultiscripts")
end
|
#mn_value=(value) ⇒ Object
204
205
206
207
208
209
210
211
212
213
214
|
# File 'lib/plurimath/math/function/fenced.rb', line 204
def mn_value=(value)
return if value.nil? || value.empty?
update(
replace_order_with_value(
@parameter_two,
Array(validate_symbols(value)),
"mn"
)
)
end
|
#mo_value=(value) ⇒ Object
228
229
230
231
232
233
234
235
236
237
238
|
# File 'lib/plurimath/math/function/fenced.rb', line 228
def mo_value=(value)
return if value.nil? || value.empty?
update(
replace_order_with_value(
@parameter_two,
Array(validate_symbols(value)),
"mo"
)
)
end
|
#mover_value=(value) ⇒ Object
264
265
266
|
# File 'lib/plurimath/math/function/fenced.rb', line 264
def mover_value=(value)
update_temp_order(value, "mover")
end
|
#mpadded_value=(value) ⇒ Object
335
336
337
|
# File 'lib/plurimath/math/function/fenced.rb', line 335
def mpadded_value=(value)
update_temp_order(value, "mpadded")
end
|
#mphantom_value=(value) ⇒ Object
347
348
349
|
# File 'lib/plurimath/math/function/fenced.rb', line 347
def mphantom_value=(value)
update_temp_order(value, "mphantom")
end
|
#mrow_value=(value) ⇒ Object
300
301
302
303
304
305
306
307
308
309
310
311
312
|
# File 'lib/plurimath/math/function/fenced.rb', line 300
def mrow_value=(value)
return if value.nil? || value.empty?
update(
replace_order_with_value(
Array(@parameter_two),
update_temp_mathml_values(
Array(filter_values(value, array_to_instance: true))
),
"mrow"
)
)
end
|
#mspace_value=(value) ⇒ Object
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
|
# File 'lib/plurimath/math/function/fenced.rb', line 314
def mspace_value=(value)
return if value.nil? || value.empty?
if value.first.linebreak
linebreak = Math::Function::Linebreak.new(
nil,
{ linebreak: value.first.linebreak }
)
update(
replace_order_with_value(
Array(@parameter_two),
[linebreak],
"mspace"
)
)
else
@parameter_two&.delete("mspace")
end
end
|
#msqrt_value=(value) ⇒ Object
280
281
282
|
# File 'lib/plurimath/math/function/fenced.rb', line 280
def msqrt_value=(value)
update_temp_order(value, "msqrt")
end
|
#mstyle_value=(value) ⇒ Object
240
241
242
243
244
245
246
247
248
249
250
|
# File 'lib/plurimath/math/function/fenced.rb', line 240
def mstyle_value=(value)
return if value.empty?
update(
replace_order_with_value(
@parameter_two,
Array(value),
"mstyle"
)
)
end
|
#msub_value=(value) ⇒ Object
256
257
258
|
# File 'lib/plurimath/math/function/fenced.rb', line 256
def msub_value=(value)
update_temp_order(value, "msub")
end
|
#msubsup_value=(value) ⇒ Object
272
273
274
|
# File 'lib/plurimath/math/function/fenced.rb', line 272
def msubsup_value=(value)
update_temp_order(value, "msubsup")
end
|
#msup_value=(value) ⇒ Object
260
261
262
|
# File 'lib/plurimath/math/function/fenced.rb', line 260
def msup_value=(value)
update_temp_order(value, "msup")
end
|
#mtable_value=(value) ⇒ Object
288
289
290
291
292
293
294
295
296
297
298
|
# File 'lib/plurimath/math/function/fenced.rb', line 288
def mtable_value=(value)
return if value.nil? || value.empty?
update(
replace_order_with_value(
Array(@parameter_two),
update_temp_mathml_values(value),
"mtable"
)
)
end
|
#mtext_value=(value) ⇒ Object
216
217
218
219
220
221
222
223
224
225
226
|
# File 'lib/plurimath/math/function/fenced.rb', line 216
def mtext_value=(value)
return if value.nil? || value.empty?
update(
replace_order_with_value(
@parameter_two,
Array(validate_symbols(value)),
"mtext"
)
)
end
|
#munder_value=(value) ⇒ Object
268
269
270
|
# File 'lib/plurimath/math/function/fenced.rb', line 268
def munder_value=(value)
update_temp_order(value, "munder")
end
|
#munderover_value=(value) ⇒ Object
252
253
254
|
# File 'lib/plurimath/math/function/fenced.rb', line 252
def munderover_value=(value)
update_temp_order(value, "munderover")
end
|
#open=(value) ⇒ Object
176
177
178
179
180
|
# File 'lib/plurimath/math/function/fenced.rb', line 176
def open=(value)
return unless value
@parameter_one = validate_symbols(value)
end
|
#separators=(value) ⇒ Object
163
164
165
166
167
|
# File 'lib/plurimath/math/function/fenced.rb', line 163
def separators=(value)
return if value.nil?
@options[:separators] = value
end
|
#to_asciimath(options:) ⇒ Object
28
29
30
31
32
33
|
# File 'lib/plurimath/math/function/fenced.rb', line 28
def to_asciimath(options:)
first_value = parameter_one ? parameter_one.to_asciimath(options: options) : "("
third_value = parameter_three ? parameter_three.to_asciimath(options: options) : ")"
second_value = parameter_two&.map { |param| param.to_asciimath(options: options) }&.join(' ')
"#{first_value}#{second_value}#{third_value}"
end
|
#to_asciimath_math_zone(spacing, last = false, indent = true, options:) ⇒ Object
100
101
102
103
104
105
|
# File 'lib/plurimath/math/function/fenced.rb', line 100
def to_asciimath_math_zone(spacing, last = false, indent = true, options:)
filtered_values(parameter_two, lang: :asciimath).map.with_index(1) do |object, index|
new_last = index == @values.length && last
object.to_asciimath_math_zone(spacing, new_last, indent, options: options)
end
end
|
#to_html(options:) ⇒ Object
49
50
51
52
53
54
|
# File 'lib/plurimath/math/function/fenced.rb', line 49
def to_html(options:)
first_value = "<i>#{symbol_or_paren(parameter_one, lang: :html, options: options)}</i>" if parameter_one
second_value = parameter_two.map { |param| param.to_html(options: options) }.join if parameter_two
third_value = "<i>#{symbol_or_paren(parameter_three, lang: :html, options: options)}</i>" if parameter_three
"#{first_value}#{second_value}#{third_value}"
end
|
#to_latex(options:) ⇒ Object
56
57
58
59
60
61
|
# File 'lib/plurimath/math/function/fenced.rb', line 56
def to_latex(options:)
fenced_value = parameter_two&.map { |param| param.to_latex(options: options) }&.join(" ")
first_value = latex_paren(symbol_or_paren(parameter_one, lang: :latex, options: options))
second_value = latex_paren(symbol_or_paren(parameter_three, lang: :latex, options: options))
"#{first_value} #{fenced_value} #{second_value}"
end
|
#to_latex_math_zone(spacing, last = false, indent = true, options:) ⇒ Object
107
108
109
110
111
112
|
# File 'lib/plurimath/math/function/fenced.rb', line 107
def to_latex_math_zone(spacing, last = false, indent = true, options:)
filtered_values(parameter_two, lang: :latex).map.with_index(1) do |object, index|
new_last = index == @values.length && last
object.to_latex_math_zone(spacing, new_last, indent, options: options)
end
end
|
#to_mathml_math_zone(spacing, last = false, indent = true, options:) ⇒ Object
114
115
116
117
118
119
|
# File 'lib/plurimath/math/function/fenced.rb', line 114
def to_mathml_math_zone(spacing, last = false, indent = true, options:)
filtered_values(parameter_two, lang: :mathml, options: options).map.with_index(1) do |object, index|
new_last = index == @values.length && last
object.to_mathml_math_zone(spacing, new_last, indent, options: options)
end
end
|
#to_mathml_without_math_tag(intent, options:) ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/plurimath/math/function/fenced.rb', line 35
def to_mathml_without_math_tag(intent, options:)
first_value = ox_element("mo", attributes: self.options&.dig(:open_paren)) << (mathml_paren(parameter_one, intent, options: options) || "")
third_value = ox_element("mo", attributes: self.options&.dig(:close_paren)) << (mathml_paren(parameter_three, intent, options: options) || "")
mrow_value = Array(mathml_value(intent, options: options))&.insert(0, first_value) << third_value
fenced = Utility.update_nodes(ox_element("mrow"), mrow_value)
intentify(
fenced,
intent,
func_name: :interval_fence,
intent_name: intent_value(mrow_value, options: options),
options: intent_names,
)
end
|
#to_omml_math_zone(spacing, last = false, indent = true, display_style:, options:) ⇒ Object
121
122
123
124
125
|
# File 'lib/plurimath/math/function/fenced.rb', line 121
def to_omml_math_zone(spacing, last = false, indent = true, display_style:, options:)
filtered_values(parameter_two, lang: :omml).map do |object|
object.to_omml_math_zone(spacing, last, !indent, display_style: display_style, options: options)
end
end
|
#to_omml_without_math_tag(display_style, options:) ⇒ Object
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/plurimath/math/function/fenced.rb', line 63
def to_omml_without_math_tag(display_style, options:)
attrs = { "m:val": (options ? options[:separators] : "") }
d = Utility.ox_element("d", namespace: "m")
dpr = Utility.ox_element("dPr", namespace: "m")
open_paren(dpr, options: options)
dpr << Utility.ox_element("sepChr", namespace: "m", attributes: attrs)
close_paren(dpr, options: options)
Utility.update_nodes(
d,
[
dpr,
omml_parameter(
Formula.new(Array(parameter_two)),
display_style,
tag_name: "e",
options: options,
),
],
)
[d]
end
|
#to_unicodemath(options:) ⇒ Object
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
# File 'lib/plurimath/math/function/fenced.rb', line 85
def to_unicodemath(options:)
return mini_sized_unicode(options: options) if mini_sized?
fenced_value = parameter_two&.map do |param|
next param.choose_frac(options: options) if choose_frac?(param)
param.to_unicodemath(options: options)
end&.join(" ")
return fenced_value if choose_frac?(parameter_two.first)
fenced_value = "(#{fenced_value})" if vert_paren?
"#{unicode_open_paren(options: options)}#{fenced_value}#{unicode_close_paren(options: options)}"
end
|
#to_unicodemath_math_zone(spacing, last = false, indent = true, options:) ⇒ Object
127
128
129
130
131
132
|
# File 'lib/plurimath/math/function/fenced.rb', line 127
def to_unicodemath_math_zone(spacing, last = false, indent = true, options:)
filtered_values(parameter_two, lang: :unicodemath).map.with_index(1) do |object, index|
new_last = index == @values.length && last
object.to_unicodemath_math_zone(spacing, new_last, indent, options: options)
end
end
|