Class: Plurimath::Math::Symbol
- Inherits:
-
Core
- Object
- Core
- Plurimath::Math::Symbol
show all
- Defined in:
- lib/plurimath/math/symbol.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Core
#ascii_fields_to_print, #class_name, #common_math_zone_conversion, #dump_mathml, #dump_omml, #dump_ox_nodes, #empty_tag, #extract_class_from_text, #extractable?, #filtered_values, #gsub_spacing, #invert_unicode_symbols, #latex_fields_to_print, #mathml_fields_to_print, #omml_fields_to_print, #omml_parameter, #r_element, #validate_mathml_fields
Constructor Details
#initialize(sym) ⇒ Symbol
Returns a new instance of Symbol.
8
9
10
|
# File 'lib/plurimath/math/symbol.rb', line 8
def initialize(sym)
@value = sym.is_a?(Parslet::Slice) ? sym.to_s : sym
end
|
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
6
7
8
|
# File 'lib/plurimath/math/symbol.rb', line 6
def value
@value
end
|
Instance Method Details
#==(object) ⇒ Object
12
13
14
|
# File 'lib/plurimath/math/symbol.rb', line 12
def ==(object)
object.respond_to?(:value) && object.value == value
end
|
#font_style_t_tag(_display_style) ⇒ Object
79
80
81
|
# File 'lib/plurimath/math/symbol.rb', line 79
def font_style_t_tag(_display_style)
t_tag
end
|
#insert_t_tag(_display_style) ⇒ Object
63
64
65
|
# File 'lib/plurimath/math/symbol.rb', line 63
def insert_t_tag(_display_style)
[(Utility.ox_element("r", namespace: "m") << t_tag)]
end
|
#nary_attr_value ⇒ Object
83
84
85
|
# File 'lib/plurimath/math/symbol.rb', line 83
def nary_attr_value
value
end
|
#omml_nodes(display_style) ⇒ Object
91
92
93
|
# File 'lib/plurimath/math/symbol.rb', line 91
def omml_nodes(display_style)
Array(t_tag)
end
|
#omml_tag_name ⇒ Object
71
72
73
74
75
76
77
|
# File 'lib/plurimath/math/symbol.rb', line 71
def omml_tag_name
if ["⋀", "⋁", "⋂", "⋃", "⋃", "∑", "∏"].include?(value)
return "undOvr"
end
"subSup"
end
|
#t_tag ⇒ Object
95
96
97
|
# File 'lib/plurimath/math/symbol.rb', line 95
def t_tag
Utility.ox_element("t", namespace: "m") << value
end
|
#tag_name ⇒ Object
67
68
69
|
# File 'lib/plurimath/math/symbol.rb', line 67
def tag_name
["⋀", "⋁", "⋂", "⋃"].include?(value) ? "underover" : "subsup"
end
|
#to_asciimath ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/plurimath/math/symbol.rb', line 16
def to_asciimath
return "" if value.nil?
symbol = Asciimath::Constants::SYMBOLS.invert[value.strip.to_sym]
unicodes = Latex::Constants::UNICODE_SYMBOLS.invert
if value.match?(/&#x[0-9\w]+;/) && symbol.nil? && unicodes[value]
return unicodes[value].to_s
end
symbol ? symbol.to_s : value
end
|
#to_html ⇒ Object
55
56
57
|
# File 'lib/plurimath/math/symbol.rb', line 55
def to_html
value
end
|
#to_latex ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/plurimath/math/symbol.rb', line 40
def to_latex
returned = specific_values
return returned if returned
special_char = %w[& #]
symbols = Latex::Constants::UNICODE_SYMBOLS.invert
symbol = symbols[value]
if Latex::Constants::SYMBOLS[symbol] == :operant
special_char.include?(value) ? "\\#{symbol}" : symbol
else
symbols.key?(value) ? "\\#{symbol}" : value
end
end
|
#to_mathml_without_math_tag ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/plurimath/math/symbol.rb', line 28
def to_mathml_without_math_tag
mi_tag = Utility.ox_element("mi")
return mi_tag if ["{:", ":}"].include?(value)
unicode = Mathml::Constants::UNICODE_SYMBOLS.invert[value]
if operator?(unicode) || unicode || explicit_checks(unicode)
return Utility.ox_element("mo") << (unicode || value).to_s
end
mi_tag << value
end
|
#to_omml_without_math_tag(_display_style) ⇒ Object
59
60
61
|
# File 'lib/plurimath/math/symbol.rb', line 59
def to_omml_without_math_tag(_display_style)
value
end
|
87
88
89
|
# File 'lib/plurimath/math/symbol.rb', line 87
def validate_function_formula
false
end
|