Class: Plurimath::Math::Function::Ul

Inherits:
BinaryFunction show all
Defined in:
lib/plurimath/math/function/ul.rb

Instance Attribute Summary

Attributes inherited from BinaryFunction

#parameter_one, #parameter_two

Instance Method Summary collapse

Methods inherited from BinaryFunction

#==, #all_values_exist?, #initialize, #to_html

Methods inherited from Core

#empty_tag, #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

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

Instance Method Details

#class_nameObject



45
46
47
# File 'lib/plurimath/math/function/ul.rb', line 45

def class_name
  "underline"
end

#swap_classObject



49
50
51
# File 'lib/plurimath/math/function/ul.rb', line 49

def swap_class
  Bar.new(parameter_one, parameter_two)
end

#to_asciimathObject



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

def to_asciimath
  first_value = "(#{parameter_one.to_asciimath})" if parameter_one
  "underline#{first_value}"
end

#to_latexObject



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

def to_latex
  first_value = "{#{parameter_one.to_latex}}" if parameter_one
  "\\underline#{first_value}"
end

#to_mathml_without_math_tagObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/plurimath/math/function/ul.rb', line 19

def to_mathml_without_math_tag
  mo_tag = Utility.ox_element("mo") << "&#x332;"
  return mo_tag unless parameter_one

  munder_tag = Utility.ox_element("munder")
  munder_tag.attributes.merge!(parameter_two) if parameter_two && !parameter_two.empty?
  Utility.update_nodes(
    munder_tag,
    [
      parameter_one&.to_mathml_without_math_tag,
      mo_tag,
    ],
  )
end

#to_omml_without_math_tag(display_style) ⇒ Object



34
35
36
37
38
39
40
41
42
43
# File 'lib/plurimath/math/function/ul.rb', line 34

def to_omml_without_math_tag(display_style)
  return r_element("&#x332;", rpr_tag: false) unless all_values_exist?

  if parameter_two && parameter_two[:accentunder]
    groupchr_tag(display_style)
  else
    symbol = Symbol.new("&#x332;")
    Underset.new(parameter_one, symbol).to_omml_without_math_tag(true)
  end
end