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, #mini_sized?, #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
19
20
21
22
23
|
# File 'lib/plurimath/math/function/binary_function.rb', line 19
def ==(object)
object.class == self.class &&
object.parameter_one == parameter_one &&
object.parameter_two == parameter_two
end
|
#all_values_exist? ⇒ Boolean
63
64
65
|
# File 'lib/plurimath/math/function/binary_function.rb', line 63
def all_values_exist?
!(parameter_one.nil? && parameter_two.nil?)
end
|
#any_value_exist? ⇒ Boolean
59
60
61
|
# File 'lib/plurimath/math/function/binary_function.rb', line 59
def any_value_exist?
!(parameter_one.nil? || parameter_two.nil?)
end
|
#to_asciimath(options:) ⇒ Object
15
16
17
|
# 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
67
68
69
70
71
72
73
74
|
# File 'lib/plurimath/math/function/binary_function.rb', line 67
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
46
47
48
49
50
|
# File 'lib/plurimath/math/function/binary_function.rb', line 46
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
40
41
42
43
44
|
# File 'lib/plurimath/math/function/binary_function.rb', line 40
def to_latex(options:)
first_value = latex_wrapped(parameter_one, options: options) if parameter_one
second_value = latex_wrapped(parameter_two, options: options) if parameter_two
"\\#{class_name}#{first_value}#{second_value}"
end
|
#to_latex_math_zone(spacing, last = false, _, options:) ⇒ Object
76
77
78
79
80
81
82
83
|
# File 'lib/plurimath/math/function/binary_function.rb', line 76
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
85
86
87
88
89
90
91
92
|
# File 'lib/plurimath/math/function/binary_function.rb', line 85
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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/plurimath/math/function/binary_function.rb', line 25
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
first_value = parameter_one&.to_mathml_without_math_tag(intent, options: options) if parameter_one
second_value = parameter_two&.to_mathml_without_math_tag(intent, options: options) if parameter_two
Utility.update_nodes(
mrow_tag,
[
first_value,
mo_tag,
second_value,
],
)
end
|
#to_omml_math_zone(spacing, last = false, _, display_style:, options:) ⇒ Object
94
95
96
97
98
99
100
101
|
# File 'lib/plurimath/math/function/binary_function.rb', line 94
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
52
53
54
55
56
57
|
# File 'lib/plurimath/math/function/binary_function.rb', line 52
def to_omml_without_math_tag(display_style, options:)
r_tag = Utility.ox_element("r", namespace: "m")
Utility.update_nodes(r_tag, [parameter_one.insert_t_tag(display_style, options: options)]) if parameter_one
Utility.update_nodes(r_tag, [parameter_two.insert_t_tag(display_style, options: options)]) if parameter_two
[r_tag]
end
|
#to_unicodemath_math_zone(spacing, last = false, _, options:) ⇒ Object
103
104
105
106
107
108
109
110
|
# File 'lib/plurimath/math/function/binary_function.rb', line 103
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
|