Class: Plurimath::Unitsml
- Inherits:
-
Object
- Object
- Plurimath::Unitsml
- Defined in:
- lib/plurimath/unitsml.rb
Constant Summary collapse
- VALID_UNITSML =
Match ^ followed by content containing letters (indicating variables as exponents, which are invalid) Simplified regex to avoid catastrophic backtracking (ReDoS vulnerability)
/\^\(?-?\d*[a-z]/i
Instance Attribute Summary collapse
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(text) ⇒ Unitsml
constructor
A new instance of Unitsml.
- #to_formula ⇒ Object
Constructor Details
#initialize(text) ⇒ Unitsml
Returns a new instance of Unitsml.
12 13 14 15 |
# File 'lib/plurimath/unitsml.rb', line 12 def initialize(text) @text = text raise Math::ParseError.new(text, :invalid_unitsml) 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 |