Class: Plurimath::Unitsml
- Inherits:
-
Object
- Object
- Plurimath::Unitsml
- Defined in:
- lib/plurimath/unitsml.rb
Constant Summary collapse
- VALID_UNITSML =
%r{\^(([^\s][^*\/,"]*?[a-z]+)|(\([^-\d]+\)|[^\(\d-]+))}
Instance Attribute Summary collapse
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
- #error_message ⇒ Object
-
#initialize(text) ⇒ Unitsml
constructor
A new instance of Unitsml.
- #to_formula ⇒ Object
Constructor Details
#initialize(text) ⇒ Unitsml
Returns a new instance of Unitsml.
10 11 12 13 |
# File 'lib/plurimath/unitsml.rb', line 10 def initialize(text) @text = text raise Math::ParseError.new() if text.match?(VALID_UNITSML) end |
Instance Attribute Details
#text ⇒ Object
Returns the value of attribute text.
6 7 8 |
# File 'lib/plurimath/unitsml.rb', line 6 def text @text end |
Instance Method Details
#error_message ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/plurimath/unitsml.rb', line 19 def <<~MESSAGE [plurimath] Invalid formula `#{@text}`. [plurimath] The use of a variable as an exponent is not valid. [plurimath] If this is a bug, please report the formula at our issue tracker at: [plurimath] https://github.com/plurimath/plurimath/issues MESSAGE end |