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
Base, Color, FontStyle, Frac, Inf, Lim, Log, Menclose, Merror, Mod, Over, Overset, Power, Root, Semantics, Stackrel, Substack, Td, Underset
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Core
#class_name, #extract_class_from_text, #extractable?, #font_style_t_tag, #insert_t_tag, #nary_attr_value, #omml_parameter, #omml_tag_name, #r_element, #tag_name, #validate_function_formula
Constructor Details
#initialize(parameter_one = nil, parameter_two = nil) ⇒ BinaryFunction
Returns a new instance of BinaryFunction.
[View source]
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([parameter_one, parameter_two])
end
|
Instance Attribute Details
#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
[View source]
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
[View source]
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
[View source]
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 ⇒ Object
[View source]
15
16
17
|
# File 'lib/plurimath/math/function/binary_function.rb', line 15
def to_asciimath
"#{class_name}#{wrapped(parameter_one)}#{wrapped(parameter_two)}"
end
|
#to_html ⇒ Object
[View source]
46
47
48
49
50
|
# File 'lib/plurimath/math/function/binary_function.rb', line 46
def to_html
first_value = "<i>#{parameter_one.to_html}</i>" if parameter_one
second_value = "<i>#{parameter_two.to_html}</i>" if parameter_two
"#{first_value}#{second_value}"
end
|
#to_latex ⇒ Object
[View source]
40
41
42
43
44
|
# File 'lib/plurimath/math/function/binary_function.rb', line 40
def to_latex
first_value = latex_wrapped(parameter_one) if parameter_one
second_value = latex_wrapped(parameter_two) if parameter_two
"\\#{class_name}#{first_value}#{second_value}"
end
|
#to_mathml_without_math_tag ⇒ Object
[View source]
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
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 if parameter_one
second_value = parameter_two&.to_mathml_without_math_tag if parameter_two
Utility.update_nodes(
mrow_tag,
[
first_value,
mo_tag,
second_value,
],
)
end
|
#to_omml_without_math_tag(display_style) ⇒ Object
[View source]
52
53
54
55
56
57
|
# File 'lib/plurimath/math/function/binary_function.rb', line 52
def to_omml_without_math_tag(display_style)
r_tag = Utility.ox_element("r", namespace: "m")
Utility.update_nodes(r_tag, [parameter_one.insert_t_tag(display_style)]) if parameter_one
Utility.update_nodes(r_tag, [parameter_two.insert_t_tag(display_style)]) if parameter_two
[r_tag]
end
|