Class: Plurimath::Math::Function::Linebreak

Inherits:
UnaryFunction show all
Defined in:
lib/plurimath/math/function/linebreak.rb

Constant Summary

Constants inherited from Core

Core::REPLACABLES

Instance Attribute Summary collapse

Attributes inherited from UnaryFunction

#hide_function_name, #parameter_one

Instance Method Summary collapse

Methods inherited from UnaryFunction

#custom_array_line_breaking, #intent_names, #reprocess_parameter_one, #to_asciimath_math_zone, #to_latex_math_zone, #to_mathml_math_zone, #to_omml_math_zone, #to_unicodemath_math_zone, #update, #value_nil?

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, #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, #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, attributes = {}) ⇒ Linebreak

Returns a new instance of Linebreak.



11
12
13
14
15
# File 'lib/plurimath/math/function/linebreak.rb', line 11

def initialize(parameter_one = nil, attributes = {})
  @parameter_one = parameter_one
  @attributes = attributes
  Utility.validate_left_right([parameter_one])
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



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

def attributes
  @attributes
end

Instance Method Details

#==(object) ⇒ Object



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

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

#linebreakObject



94
95
96
# File 'lib/plurimath/math/function/linebreak.rb', line 94

def linebreak
  true
end

#omml_line_break(result) ⇒ Object



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

def omml_line_break(result)
  result.first.pop
  return result unless exist?

  case attributes[:linebreakstyle]
  when "after"
    result[0] << parameter_one
  else
    result[1].insert(0, parameter_one)
  end
  result
end

#separate_tableObject



90
91
92
# File 'lib/plurimath/math/function/linebreak.rb', line 90

def separate_table
  true
end

#to_asciimath(options:) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/plurimath/math/function/linebreak.rb', line 23

def to_asciimath(options:)
  linebreak_character = "\\\n "
  return linebreak_character unless parameter_one

  case attributes[:linebreakstyle]
  when "after"
    "#{asciimath_value(options: options)}#{linebreak_character}"
  else
    "#{linebreak_character}#{asciimath_value(options: options)}"
  end
end

#to_html(options:) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
# File 'lib/plurimath/math/function/linebreak.rb', line 56

def to_html(options:)
  br_tag = "<br/>"
  return br_tag unless parameter_one

  case attributes[:linebreakstyle]
  when "after"
    "#{parameter_one.to_html(options: options)}#{br_tag}"
  else
    "#{br_tag}#{parameter_one.to_html(options: options)}"
  end
end

#to_latex(options:) ⇒ Object



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

def to_latex(options:)
  linebreak_character = "\\\\ "
  return linebreak_character unless parameter_one

  case attributes[:linebreakstyle]
  when "after"
    "#{latex_value(options: options)}#{linebreak_character}"
  else
    "#{linebreak_character}#{latex_value(options: options)}"
  end
end

#to_mathml_without_math_tag(intent, options:) ⇒ Object



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

def to_mathml_without_math_tag(intent, options:)
  return Utility.ox_element("mo", attributes: { linebreak: "newline" }) unless parameter_one

  mo_node = parameter_one.to_mathml_without_math_tag(intent, options: options)
  mo_node.name = "mo" unless mo_node.name == "mo"
  mo_node.set_attr(attributes) unless attributes.empty?
  mo_node
end

#to_omml_without_math_tag(display_style, options:) ⇒ Object



68
69
70
# File 'lib/plurimath/math/function/linebreak.rb', line 68

def to_omml_without_math_tag(display_style, options:)
  parameter_one&.insert_t_tag(display_style, options: options)
end

#to_unicodemath(options:) ⇒ Object



85
86
87
88
# File 'lib/plurimath/math/function/linebreak.rb', line 85

def to_unicodemath(options:)
  first_value = parameter_one.to_unicodemath(options: options) if parameter_one
  "&#xa;#{first_value}"
end