Class: Plurimath::Math::Function::Fenced

Inherits:
TernaryFunction show all
Defined in:
lib/plurimath/math/function/fenced.rb

Instance Attribute Summary

Attributes inherited from TernaryFunction

#parameter_one, #parameter_three, #parameter_two

Instance Method Summary collapse

Methods inherited from TernaryFunction

#==, #initialize

Methods inherited from Core

#class_name, #empty_tag, #insert_t_tag, #nary_attr_value, #omml_parameter, #omml_tag_name, #r_element, #tag_name, #validate_function_formula

Constructor Details

This class inherits a constructor from Plurimath::Math::Function::TernaryFunction

Instance Method Details

#to_asciimathObject



9
10
11
12
13
# File 'lib/plurimath/math/function/fenced.rb', line 9

def to_asciimath
  first_value  = parameter_one ? parameter_one.to_asciimath : "("
  third_value  = parameter_three ? parameter_three.to_asciimath : ")"
  "#{first_value}#{parameter_two&.map(&:to_asciimath)&.join(' ')}#{third_value}"
end

#to_htmlObject



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

def to_html
  first_value  = "<i>#{parameter_one.value}</i>" if parameter_one
  second_value = parameter_two.map(&:to_html).join if parameter_two
  third_value  = "<i>#{parameter_three.value}</i>" if parameter_three
  "#{first_value}#{second_value}#{third_value}"
end

#to_latexObject



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

def to_latex
  open_paren   = parameter_one ? parameter_one.value : "("
  fenced_value = parameter_two&.map(&:to_latex)&.join(" ")
  close_paren  = parameter_three ? parameter_three.value : ")"
  first_value  = latex_paren(open_paren)
  second_value = latex_paren(close_paren)
  "#{first_value} #{fenced_value} #{second_value}"
end

#to_mathml_without_math_tagObject



15
16
17
18
19
20
21
22
23
# File 'lib/plurimath/math/function/fenced.rb', line 15

def to_mathml_without_math_tag
  first_value = Utility.ox_element("mo") << (mathml_paren(parameter_one) || "")
  second_value = parameter_two&.map(&:to_mathml_without_math_tag) || []
  third_value = Utility.ox_element("mo") << (mathml_paren(parameter_three) || "")
  Utility.update_nodes(
    Utility.ox_element("mrow"),
    (second_value.insert(0, first_value) << third_value),
  )
end

#to_omml_without_math_tagObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/plurimath/math/function/fenced.rb', line 41

def to_omml_without_math_tag
  d = Utility.ox_element("d", namespace: "m")
  dpr = Utility.ox_element("dPr", namespace: "m")
  first_value(dpr)
  third_value(dpr)
  dpr << Utility.pr_element("ctrl", true, namespace: "m")
  Utility.update_nodes(
    d,
    [
      dpr,
      omml_parameter(
        Formula.new(Array(parameter_two)),
        tag_name: "e",
      ),
    ],
  )
  [d]
end