Module: Paf::CoreExt::String
- Defined in:
- lib/paf/core_ext/string.rb
Overview
Extend the core String class with PAF specific processing
Instance Method Summary collapse
- #but_last_word ⇒ Object
- #exception? ⇒ Boolean
- #known_building_type? ⇒ Boolean
- #last_word ⇒ Object
- #split_exception? ⇒ Boolean
Instance Method Details
#but_last_word ⇒ Object
17 18 19 |
# File 'lib/paf/core_ext/string.rb', line 17 def but_last_word self[0...rindex(' ')] end |
#exception? ⇒ Boolean
5 6 7 |
# File 'lib/paf/core_ext/string.rb', line 5 def exception? !/^(.|[\d][[:alpha:]]|[\d].*?[\d][[:alpha:]]?)$/.match(self).nil? end |
#known_building_type? ⇒ Boolean
21 22 23 24 25 26 |
# File 'lib/paf/core_ext/string.rb', line 21 def known_building_type? [ 'BACK OF', 'BLOCK', 'BLOCKS', 'BUILDING', 'MAISONETTE', 'MAISONETTES', 'REAR OF', 'SHOP', 'SHOPS', 'STALL', 'STALLS', 'SUITE', 'SUITES', 'UNIT', 'UNITS' ].include?(self) end |
#last_word ⇒ Object
13 14 15 |
# File 'lib/paf/core_ext/string.rb', line 13 def last_word split.last end |
#split_exception? ⇒ Boolean
9 10 11 |
# File 'lib/paf/core_ext/string.rb', line 9 def split_exception? last_word.exception? && /^\d+$/.match(last_word).nil? && !but_last_word.known_building_type? end |