Class: Pug::NumberParser
- Inherits:
-
Object
- Object
- Pug::NumberParser
- Defined in:
- lib/pug/number_parser.rb
Overview
Parses numeric values from text
Instance Method Summary collapse
-
#number_from_text(text) ⇒ Integer?
Extracts number from text if it starts with a number.
-
#starts_with_numeric_text?(text) ⇒ Boolean
Indicates if a text starts with a number.
Instance Method Details
#number_from_text(text) ⇒ Integer?
Extracts number from text if it starts with a number
17 18 19 20 |
# File 'lib/pug/number_parser.rb', line 17 def number_from_text(text) return nil unless starts_with_numeric_text?(text) text.to_i end |
#starts_with_numeric_text?(text) ⇒ Boolean
Indicates if a text starts with a number
9 10 11 |
# File 'lib/pug/number_parser.rb', line 9 def starts_with_numeric_text?(text) text.to_i.positive? || text.strip.start_with?('0') end |