Class: Plurimath::Math::Function::TernaryFunction

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

Direct Known Subclasses

Fenced, Int, Limits, Multiscript, Oint, PowerBase, Prod, Rule, Sum, Underover

Constant Summary

Constants inherited from Core

Core::REPLACABLES

Instance Attribute Summary collapse

Instance Method Summary collapse

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_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, #prime_unicode?, #r_element, #replacable_values, #result, #separate_table, #set, #tag_name, #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, parameter_three = nil) ⇒ TernaryFunction

Returns a new instance of TernaryFunction.



9
10
11
12
13
14
15
16
# File 'lib/plurimath/math/function/ternary_function.rb', line 9

def initialize(parameter_one = nil,
               parameter_two = nil,
               parameter_three = nil)
  @parameter_one = parameter_one
  @parameter_two = parameter_two
  @parameter_three = parameter_three
  Utility.validate_left_right(variables.map { |var| get(var) })
end

Instance Attribute Details

#hide_function_nameObject

Returns the value of attribute hide_function_name.



7
8
9
# File 'lib/plurimath/math/function/ternary_function.rb', line 7

def hide_function_name
  @hide_function_name
end

#parameter_oneObject

Returns the value of attribute parameter_one.



7
8
9
# File 'lib/plurimath/math/function/ternary_function.rb', line 7

def parameter_one
  @parameter_one
end

#parameter_threeObject

Returns the value of attribute parameter_three.



7
8
9
# File 'lib/plurimath/math/function/ternary_function.rb', line 7

def parameter_three
  @parameter_three
end

#parameter_twoObject

Returns the value of attribute parameter_two.



7
8
9
# File 'lib/plurimath/math/function/ternary_function.rb', line 7

def parameter_two
  @parameter_two
end

Instance Method Details

#==(object) ⇒ Object



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

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

#all_values_exist?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/plurimath/math/function/ternary_function.rb', line 60

def all_values_exist?
  !(parameter_one.nil? && parameter_two.nil? && parameter_three.nil?)
end

#any_value_exist?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/plurimath/math/function/ternary_function.rb', line 56

def any_value_exist?
  !(parameter_one.nil? || parameter_two.nil? || parameter_three.nil?)
end

#to_asciimath(options:) ⇒ Object



25
26
27
28
29
30
# File 'lib/plurimath/math/function/ternary_function.rb', line 25

def to_asciimath(options:)
  first_value = first_field_wrap(parameter_one, options: options) if parameter_one
  second_value = "_#{wrapped(parameter_two, options: options)}" if parameter_two
  third_value = "^#{wrapped(parameter_three, options: options)}" if parameter_three
  "#{first_value}#{second_value}#{third_value}"
end

#to_asciimath_math_zone(spacing, last = false, _, options:) ⇒ Object



64
65
66
67
68
69
70
71
72
# File 'lib/plurimath/math/function/ternary_function.rb', line 64

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 })
  ascii_fields_to_print(parameter_three, { spacing: new_spacing, field_name: parameters[:third_value], additional_space: "   |_ ", array: new_arr, options: options })
  new_arr
end

#to_html(options:) ⇒ Object



49
50
51
52
53
54
# File 'lib/plurimath/math/function/ternary_function.rb', line 49

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
  third_value = "<i>#{parameter_three.to_html(options: options)}</i>" if parameter_three
  "#{first_value}#{second_value}#{third_value}"
end

#to_latex(options:) ⇒ Object



42
43
44
45
46
47
# File 'lib/plurimath/math/function/ternary_function.rb', line 42

def to_latex(options:)
  first_value  = parameter_one&.to_latex(options: options)
  second_value = parameter_two&.to_latex(options: options)
  third_value  = parameter_three&.to_latex(options: options)
  "#{first_value}#{second_value}#{third_value}"
end

#to_latex_math_zone(spacing, last = false, _, options:) ⇒ Object



74
75
76
77
78
79
80
81
82
# File 'lib/plurimath/math/function/ternary_function.rb', line 74

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 })
  latex_fields_to_print(parameter_three, { spacing: new_spacing, field_name: parameters[:third_value], additional_space: "   |_ ", array: new_arr, options: options })
  new_arr
end

#to_mathml_math_zone(spacing, last = false, _, options:) ⇒ Object



84
85
86
87
88
89
90
91
92
# File 'lib/plurimath/math/function/ternary_function.rb', line 84

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 })
  mathml_fields_to_print(parameter_three, { spacing: new_spacing, field_name: parameters[:third_value], additional_space: "   |_ ", array: new_arr, options: options })
  new_arr
end

#to_mathml_without_math_tag(intent, options:) ⇒ Object



32
33
34
35
36
37
38
39
40
# File 'lib/plurimath/math/function/ternary_function.rb', line 32

def to_mathml_without_math_tag(intent, options:)
  value_arr = [
    validate_mathml_fields(parameter_one, intent, options: options),
    validate_mathml_fields(parameter_two, intent, options: options),
    validate_mathml_fields(parameter_three, intent, options: options),
  ]
  class_tag = ox_element("m#{class_name}")
  Utility.update_nodes(class_tag, value_arr)
end

#to_omml_math_zone(spacing, last = false, _, display_style:, options:) ⇒ Object



94
95
96
97
98
99
100
101
102
# File 'lib/plurimath/math/function/ternary_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 })
  omml_fields_to_print(parameter_three, { spacing: new_spacing, field_name: parameters[:third_value], additional_space: "   |_ ", array: new_arr, display_style: display_style, options: options })
  new_arr
end

#to_unicodemath_math_zone(spacing, last = false, _, options:) ⇒ Object



104
105
106
107
108
109
110
111
112
# File 'lib/plurimath/math/function/ternary_function.rb', line 104

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 })
  unicodemath_fields_to_print(parameter_three, { spacing: new_spacing, field_name: parameters[:third_value], additional_space: "   |_ ", array: new_arr, options: options })
  new_arr
end