Class: Plurimath::Math::Number
- Inherits:
-
Core
- Object
- Core
- Plurimath::Math::Number
show all
- Defined in:
- lib/plurimath/math/number.rb
Constant Summary
Constants inherited
from Core
Core::ALL_PARAMETERS, Core::REPLACABLES
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Core
#ascii_fields_to_print, #class_name, #cloned_objects, #close?, #common_math_zone_conversion, descendants, #divide_operator?, #dump_mathml, #dump_nodes, #dump_omml, #dump_ox_nodes, #empty_tag, #extract_class_name_from_text, #extractable?, #filtered_values, #get, #gsub_spacing, inherited, #invert_unicode_symbols, #is_binary_function?, #is_mrow?, #is_mstyle?, #is_nary_function?, #is_nary_symbol?, #is_ternary_function?, #is_unary?, #latex_fields_to_print, #line_breaking, #linebreak?, #mathml_fields_to_print, #mathml_nodes, #minus_operator?, #msty_tag_with_attrs, #multiply_operator?, #nary_intent_name, #omml_fields_to_print, #omml_nodes, #omml_parameter, #omml_tag_name, #open?, #operator?, #ox_element, #paren?, #plus_operator?, #power_operator?, #pretty_print_instance_variables, #prime_unicode?, #r_element, #replacable_values, #reserved_constant, #result, #separate_table, #set, #symbol?, #tag_name, #to_ms_value, #unicodemath_fields_to_print, #unicodemath_parens, #updated_object_values, #validate_mathml_fields, #variable_name, #variable_value, #variables
Constructor Details
#initialize(value = nil, mini_sub_sized: false, mini_sup_sized: false, base: nil) ⇒ Number
Returns a new instance of Number.
8
9
10
11
12
13
14
|
# File 'lib/plurimath/math/number.rb', line 8
def initialize(value = nil, mini_sub_sized: false, mini_sup_sized: false,
base: nil)
@value = value.is_a?(::Parslet::Slice) ? value.to_s : value
@mini_sub_sized = mini_sub_sized
@mini_sup_sized = mini_sup_sized
@base = base
end
|
Instance Attribute Details
#base ⇒ Object
Returns the value of attribute base.
6
7
8
|
# File 'lib/plurimath/math/number.rb', line 6
def base
@base
end
|
#mini_sub_sized ⇒ Object
Returns the value of attribute mini_sub_sized.
6
7
8
|
# File 'lib/plurimath/math/number.rb', line 6
def mini_sub_sized
@mini_sub_sized
end
|
#mini_sup_sized ⇒ Object
Returns the value of attribute mini_sup_sized.
6
7
8
|
# File 'lib/plurimath/math/number.rb', line 6
def mini_sup_sized
@mini_sup_sized
end
|
#value ⇒ Object
Returns the value of attribute value.
6
7
8
|
# File 'lib/plurimath/math/number.rb', line 6
def value
@value
end
|
Instance Method Details
#==(object) ⇒ Object
16
17
18
19
20
21
22
|
# File 'lib/plurimath/math/number.rb', line 16
def ==(object)
object.is_a?(Number) &&
object.value == value &&
object.mini_sub_sized == mini_sub_sized &&
object.mini_sup_sized == mini_sup_sized &&
object.base == base
end
|
#element_order= ⇒ Object
24
|
# File 'lib/plurimath/math/number.rb', line 24
def element_order=(*); end
|
#evaluate(_evaluator) ⇒ Object
84
85
86
87
88
89
90
91
|
# File 'lib/plurimath/math/number.rb', line 84
def evaluate(_evaluator)
raw_value = value.to_s
return raw_value.to_i if raw_value.match?(/\A[+-]?\d+\z/)
Float(raw_value)
rescue ArgumentError
raise Errors::Evaluation::UnsupportedExpressionError, "number `#{raw_value}`"
end
|
#font_style_t_tag(_, options:) ⇒ Object
67
68
69
|
# File 'lib/plurimath/math/number.rb', line 67
def font_style_t_tag(_, options:)
t_tag(options: options)
end
|
#insert_t_tag(_, options:) ⇒ Object
61
62
63
64
65
|
# File 'lib/plurimath/math/number.rb', line 61
def insert_t_tag(_, options:)
[
Utility.ox_element("r", namespace: "m") << t_tag(options: options),
]
end
|
#mini_sized? ⇒ Boolean
93
94
95
|
# File 'lib/plurimath/math/number.rb', line 93
def mini_sized?
mini_sub_sized || mini_sup_sized
end
|
#nary_attr_value(options:) ⇒ Object
76
77
78
|
# File 'lib/plurimath/math/number.rb', line 76
def nary_attr_value(options:)
format_value_with_options(options).to_s
end
|
#t_tag(options:) ⇒ Object
71
72
73
74
|
# File 'lib/plurimath/math/number.rb', line 71
def t_tag(options:)
Utility.ox_element("t",
namespace: "m") << formatted_value(options)
end
|
#to_asciimath(options:) ⇒ Object
26
27
28
29
30
|
# File 'lib/plurimath/math/number.rb', line 26
def to_asciimath(options:)
Formatter::Numbers::TextRenderer.render(
format_value_with_options(options), :asciimath
)
end
|
#to_html(options:) ⇒ Object
42
43
44
45
46
|
# File 'lib/plurimath/math/number.rb', line 42
def to_html(options:)
Formatter::Numbers::TextRenderer.render(
format_value_with_options(options), :html
)
end
|
#to_latex(options:) ⇒ Object
36
37
38
39
40
|
# File 'lib/plurimath/math/number.rb', line 36
def to_latex(options:)
Formatter::Numbers::TextRenderer.render(
format_value_with_options(options), :latex
)
end
|
#to_mathml_without_math_tag(_, options:) ⇒ Object
32
33
34
|
# File 'lib/plurimath/math/number.rb', line 32
def to_mathml_without_math_tag(_, options:)
Formatter::Numbers::MathmlRenderer.render(format_value_with_options(options))
end
|
#to_omml_without_math_tag(_, options:) ⇒ Object
48
49
50
|
# File 'lib/plurimath/math/number.rb', line 48
def to_omml_without_math_tag(_, options:)
[Formatter::Numbers::OmmlRenderer.render(format_value_with_options(options))]
end
|
#to_unicodemath(options:) ⇒ Object
52
53
54
55
56
57
58
59
|
# File 'lib/plurimath/math/number.rb', line 52
def to_unicodemath(options:)
return mini_sub if mini_sub_sized
return mini_sup if mini_sup_sized
Formatter::Numbers::TextRenderer.render(
format_value_with_options(options), :unicodemath
)
end
|
80
81
82
|
# File 'lib/plurimath/math/number.rb', line 80
def validate_function_formula
false
end
|