Class: Plurimath::Math::Function::BinaryFunction

Inherits:
Core
  • Object
show all
Defined in:
lib/plurimath/math/function/binary_function.rb

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_oneObject

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_twoObject

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

Returns:

  • (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

Returns:

  • (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_asciimathObject



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_htmlObject



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_latexObject



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_tagObject



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