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

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

Direct Known Subclasses

Base, Color, FontStyle, Frac, Inf, Int, Lim, Log, Mod, Oint, Over, Overset, Power, Prod, Root, Stackrel, Substack, Sum, Underset

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parameter_one = nil, parameter_two = nil) ⇒ BinaryFunction

Returns a new instance of BinaryFunction.



9
10
11
12
# 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
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



24
25
26
27
28
# File 'lib/plurimath/math/function/binary_function.rb', line 24

def ==(object)
  object.class == self.class &&
    object.parameter_one == parameter_one &&
    object.parameter_two == parameter_two
end

#class_nameObject



52
53
54
# File 'lib/plurimath/math/function/binary_function.rb', line 52

def class_name
  self.class.name.split("::").last.downcase
end

#invert_unicode_symbolsObject



36
37
38
# File 'lib/plurimath/math/function/binary_function.rb', line 36

def invert_unicode_symbols
  Mathml::Constants::UNICODE_SYMBOLS.invert[class_name] || class_name
end

#to_asciimathObject



14
15
16
# File 'lib/plurimath/math/function/binary_function.rb', line 14

def to_asciimath
  "#{class_name}#{value_to_asciimath}"
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_latex}</i>" if parameter_one
  second_value = "<i>#{parameter_two.to_latex}</i>" if parameter_two
  "<i>#{class_name}</i>#{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 = "{#{parameter_one.to_latex}}" if parameter_one
  second_value = "{#{parameter_two.to_latex}}" if parameter_two
  "\\#{class_name}#{first_value}#{second_value}"
end

#to_mathml_without_math_tagObject



30
31
32
33
34
# File 'lib/plurimath/math/function/binary_function.rb', line 30

def to_mathml_without_math_tag
  first_value = parameter_one&.to_mathml_without_math_tag
  second_value = parameter_two&.to_mathml_without_math_tag
  "<mo>#{invert_unicode_symbols}</mo>#{first_value}#{second_value}"
end

#value_to_asciimathObject



18
19
20
21
22
# File 'lib/plurimath/math/function/binary_function.rb', line 18

def value_to_asciimath
  first_value = "(#{parameter_one.to_asciimath})" if parameter_one
  second_value = "(#{parameter_two.to_asciimath})" if parameter_two
  "#{first_value}#{second_value}"
end