Class: Plurimath::Math::Function::BinaryFunction
- Inherits:
-
Core
- Object
- Core
- Plurimath::Math::Function::BinaryFunction
show all
- Defined in:
- lib/plurimath/math/function/binary_function.rb
Direct Known Subclasses
Arg, Base, Color, FontStyle, Frac, Inf, Intent, Lim, Log, Menclose, Mlabeledtr, Mod, Over, Overset, Power, Root, Semantics, Stackrel, Td, Underset
Constant Summary
Constants inherited
from Core
Core::ALL_PARAMETERS, Core::REPLACABLES
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#==(object) ⇒ Object
-
#all_values_exist? ⇒ Boolean
-
#any_value_exist? ⇒ Boolean
-
#initialize(parameter_one = nil, parameter_two = nil) ⇒ BinaryFunction
constructor
A new instance of BinaryFunction.
-
#to_asciimath(options:) ⇒ Object
-
#to_asciimath_math_zone(spacing, last = false, _, options:) ⇒ Object
-
#to_html(options:) ⇒ Object
-
#to_latex(options:) ⇒ Object
-
#to_latex_math_zone(spacing, last = false, _, options:) ⇒ Object
-
#to_mathml_math_zone(spacing, last = false, _, options:) ⇒ Object
-
#to_mathml_without_math_tag(intent, options:) ⇒ Object
-
#to_omml_math_zone(spacing, last = false, _, display_style:, options:) ⇒ Object
-
#to_omml_without_math_tag(display_style, options:) ⇒ Object
-
#to_unicodemath_math_zone(spacing, last = false, _, options:) ⇒ Object
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, #line_breaking, #linebreak?, #mathml_fields_to_print, #mathml_nodes, #mini_sized?, #msty_tag_with_attrs, #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) ⇒ BinaryFunction
Returns a new instance of BinaryFunction.
9
10
11
12
13
|
# File 'lib/plurimath/math/function/binary_function.rb', line 9
def initialize(parameter_one = nil, parameter_two = nil)
@parameter_one = parameter_one
@parameter_two = parameter_two
Utility.validate_left_right(variables.map { |var| get(var) })
end
|
Instance Attribute Details
#hide_function_name ⇒ Object
Returns the value of attribute hide_function_name.
7
8
9
|
# File 'lib/plurimath/math/function/binary_function.rb', line 7
def hide_function_name
@hide_function_name
end
|
#parameter_one ⇒ Object
Returns the value of attribute parameter_one.
7
8
9
|
# File 'lib/plurimath/math/function/binary_function.rb', line 7
def parameter_one
@parameter_one
end
|
#parameter_two ⇒ Object
Returns the value of attribute parameter_two.
7
8
9
|
# File 'lib/plurimath/math/function/binary_function.rb', line 7
def parameter_two
@parameter_two
end
|
Instance Method Details
#==(object) ⇒ Object
21
22
23
24
25
|
# File 'lib/plurimath/math/function/binary_function.rb', line 21
def ==(object)
object.class == self.class &&
object.parameter_one == parameter_one &&
object.parameter_two == parameter_two
end
|
#all_values_exist? ⇒ Boolean
85
86
87
|
# File 'lib/plurimath/math/function/binary_function.rb', line 85
def all_values_exist?
parameter_one && parameter_two
end
|
#any_value_exist? ⇒ Boolean
81
82
83
|
# File 'lib/plurimath/math/function/binary_function.rb', line 81
def any_value_exist?
parameter_one || parameter_two
end
|
#to_asciimath(options:) ⇒ Object
15
16
17
18
19
|
# File 'lib/plurimath/math/function/binary_function.rb', line 15
def to_asciimath(options:)
"#{class_name}#{wrapped(parameter_one,
options: options)}#{wrapped(parameter_two,
options: options)}"
end
|
#to_asciimath_math_zone(spacing, last = false, _, options:) ⇒ Object
89
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/plurimath/math/function/binary_function.rb', line 89
def to_asciimath_math_zone(spacing, last = false, _, options:)
parameters = self.class::FUNCTION
new_spacing = gsub_spacing(spacing, last)
new_arr = ["#{spacing}\"#{to_asciimath(options: options)}\" #{parameters[:name]}\n"]
ascii_fields_to_print(parameter_one,
{ spacing: new_spacing, field_name: parameters[:first_value],
additional_space: "| |_ ", array: new_arr, options: options })
ascii_fields_to_print(parameter_two,
{ spacing: new_spacing, field_name: parameters[:second_value],
additional_space: " |_ ", array: new_arr, options: options })
new_arr
end
|
#to_html(options:) ⇒ Object
60
61
62
63
64
|
# File 'lib/plurimath/math/function/binary_function.rb', line 60
def to_html(options:)
first_value = "<i>#{parameter_one.to_html(options: options)}</i>" if parameter_one
second_value = "<i>#{parameter_two.to_html(options: options)}</i>" if parameter_two
"#{first_value}#{second_value}"
end
|
#to_latex(options:) ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/plurimath/math/function/binary_function.rb', line 48
def to_latex(options:)
if parameter_one
first_value = latex_wrapped(parameter_one,
options: options)
end
if parameter_two
second_value = latex_wrapped(parameter_two,
options: options)
end
"\\#{class_name}#{first_value}#{second_value}"
end
|
#to_latex_math_zone(spacing, last = false, _, options:) ⇒ Object
102
103
104
105
106
107
108
109
110
111
112
113
|
# File 'lib/plurimath/math/function/binary_function.rb', line 102
def to_latex_math_zone(spacing, last = false, _, options:)
parameters = self.class::FUNCTION
new_spacing = gsub_spacing(spacing, last)
new_arr = ["#{spacing}\"#{to_latex(options: options)}\" #{parameters[:name]}\n"]
latex_fields_to_print(parameter_one,
{ spacing: new_spacing, field_name: parameters[:first_value],
additional_space: "| |_ ", array: new_arr, options: options })
latex_fields_to_print(parameter_two,
{ spacing: new_spacing, field_name: parameters[:second_value],
additional_space: " |_ ", array: new_arr, options: options })
new_arr
end
|
#to_mathml_math_zone(spacing, last = false, _, options:) ⇒ Object
115
116
117
118
119
120
121
122
123
124
125
126
127
|
# File 'lib/plurimath/math/function/binary_function.rb', line 115
def to_mathml_math_zone(spacing, last = false, _, options:)
parameters = self.class::FUNCTION
new_spacing = gsub_spacing(spacing, last)
new_arr = ["#{spacing}\"#{dump_mathml(self,
options: options)}\" #{parameters[:name]}\n"]
mathml_fields_to_print(parameter_one,
{ spacing: new_spacing, field_name: parameters[:first_value],
additional_space: "| |_ ", array: new_arr, options: options })
mathml_fields_to_print(parameter_two,
{ spacing: new_spacing, field_name: parameters[:second_value],
additional_space: " |_ ", array: new_arr, options: options })
new_arr
end
|
#to_mathml_without_math_tag(intent, options:) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/plurimath/math/function/binary_function.rb', line 27
def to_mathml_without_math_tag(intent, options:)
mrow_tag = Utility.ox_element("mrow")
mo_tag = Utility.ox_element("mo") << invert_unicode_symbols.to_s
if parameter_one
first_value = parameter_one&.to_mathml_without_math_tag(intent,
options: options)
end
if parameter_two
second_value = parameter_two&.to_mathml_without_math_tag(intent,
options: options)
end
Utility.update_nodes(
mrow_tag,
[
first_value,
mo_tag,
second_value,
],
)
end
|
#to_omml_math_zone(spacing, last = false, _, display_style:, options:) ⇒ Object
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
# File 'lib/plurimath/math/function/binary_function.rb', line 129
def to_omml_math_zone(spacing, last = false, _, display_style:,
options:)
parameters = self.class::FUNCTION
new_spacing = gsub_spacing(spacing, last)
new_arr = ["#{spacing}\"#{dump_omml(self, display_style,
options: options)}\" #{parameters[:name]}\n"]
omml_fields_to_print(parameter_one,
{ spacing: new_spacing, field_name: parameters[:first_value],
additional_space: "| |_ ", array: new_arr, display_style: display_style, options: options })
omml_fields_to_print(parameter_two,
{ spacing: new_spacing, field_name: parameters[:second_value],
additional_space: " |_ ", array: new_arr, display_style: display_style, options: options })
new_arr
end
|
#to_omml_without_math_tag(display_style, options:) ⇒ Object
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/plurimath/math/function/binary_function.rb', line 66
def to_omml_without_math_tag(display_style, options:)
r_tag = Utility.ox_element("r", namespace: "m")
if parameter_one
Utility.update_nodes(r_tag,
[parameter_one.insert_t_tag(display_style,
options: options)])
end
if parameter_two
Utility.update_nodes(r_tag,
[parameter_two.insert_t_tag(display_style,
options: options)])
end
[r_tag]
end
|
#to_unicodemath_math_zone(spacing, last = false, _, options:) ⇒ Object
144
145
146
147
148
149
150
151
152
153
154
155
|
# File 'lib/plurimath/math/function/binary_function.rb', line 144
def to_unicodemath_math_zone(spacing, last = false, _, options:)
parameters = self.class::FUNCTION
new_spacing = gsub_spacing(spacing, last)
new_arr = ["#{spacing}\"#{to_unicodemath(options: options)}\" #{parameters[:name]}\n"]
unicodemath_fields_to_print(parameter_one,
{ spacing: new_spacing, field_name: parameters[:first_value],
additional_space: "| |_ ", array: new_arr, options: options })
unicodemath_fields_to_print(parameter_two,
{ spacing: new_spacing, field_name: parameters[:second_value],
additional_space: " |_ ", array: new_arr, options: options })
new_arr
end
|