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
Bar, Base, Color, Dot, FontStyle, Frac, Hat, Inf, Lim, Log, Menclose, Merror, Mod, Obrace, Over, Overset, Power, Root, Semantics, Stackrel, Substack, Td, Tilde, Ubrace, Ul, Underset, Vec
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.
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
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
59
60
61
|
# File 'lib/plurimath/math/function/binary_function.rb', line 59
def all_values_exist?
!(parameter_one.nil? && parameter_two.nil?)
end
|
#to_asciimath ⇒ Object
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
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
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
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
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
|