Module: NumbersInWords::FractionParsing
Instance Method Summary collapse
- #fraction(text) ⇒ Object
- #possible_fraction?(text) ⇒ Boolean
- #strip_punctuation(text) ⇒ Object
- #text ⇒ Object
- #text_including_punctuation ⇒ Object
Instance Method Details
#fraction(text) ⇒ Object
5 6 7 8 9 |
# File 'lib/numbers_in_words/parsing/fraction_parsing.rb', line 5 def fraction(text) return unless possible_fraction?(text) NumbersInWords.exceptional_numbers.lookup_fraction(text) end |
#possible_fraction?(text) ⇒ Boolean
20 21 22 23 24 |
# File 'lib/numbers_in_words/parsing/fraction_parsing.rb', line 20 def possible_fraction?(text) words = text.split(' ') result = words & NumbersInWords.exceptional_numbers.fraction_names result.length.positive? end |
#strip_punctuation(text) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/numbers_in_words/parsing/fraction_parsing.rb', line 11 def strip_punctuation(text) text = text.downcase.gsub(/[^a-z 0-9]/, ' ') to_remove = true to_remove = text.gsub! ' ', ' ' while to_remove text end |
#text ⇒ Object
30 31 32 |
# File 'lib/numbers_in_words/parsing/fraction_parsing.rb', line 30 def text strip_punctuation text_including_punctuation end |
#text_including_punctuation ⇒ Object
26 27 28 |
# File 'lib/numbers_in_words/parsing/fraction_parsing.rb', line 26 def text_including_punctuation to_s.strip end |