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
- #exception_i? ⇒ Boolean
- #exception_ii? ⇒ Boolean
- #exception_iii? ⇒ Boolean
- #known_building_type? ⇒ Boolean
- #known_split_building_type? ⇒ Boolean
- #last_word ⇒ Object
- #penultimate_word ⇒ Object
- #split_exception? ⇒ Boolean
Instance Method Details
#but_last_word ⇒ Object
36 37 38 |
# File 'lib/paf/core_ext/string.rb', line 36 def but_last_word self[0...rindex(' ')] end |
#exception? ⇒ Boolean
17 18 19 |
# File 'lib/paf/core_ext/string.rb', line 17 def exception? !/^(.|[\d][[:alpha:]]|[\d].*?[\d][[:alpha:]]?)$/.match(self).nil? end |
#exception_i? ⇒ Boolean
5 6 7 |
# File 'lib/paf/core_ext/string.rb', line 5 def exception_i? !/\A\d.*\d\z/.match(self).nil? end |
#exception_ii? ⇒ Boolean
9 10 11 |
# File 'lib/paf/core_ext/string.rb', line 9 def exception_ii? !/\A\d[A-Za-z]\z|\A\d.*\d[A-Za-z]\z/.match(self).nil? end |
#exception_iii? ⇒ Boolean
13 14 15 |
# File 'lib/paf/core_ext/string.rb', line 13 def exception_iii? !/\A\S\z/.match(self).nil? end |
#known_building_type? ⇒ Boolean
40 41 42 43 44 45 46 |
# File 'lib/paf/core_ext/string.rb', line 40 def known_building_type? [ 'BACK OF', 'BLOCK', 'BLOCKS', 'BUILDING', 'MAISONETTE', 'MAISONETTES', 'REAR OF', 'SHOP', 'SHOPS', 'STALL', 'STALLS', 'SUITE', 'SUITES', 'UNIT', 'UNITS', 'FLAT', 'FLATS', 'PO BOX' ].include?(self) end |
#known_split_building_type? ⇒ Boolean
48 49 50 |
# File 'lib/paf/core_ext/string.rb', line 48 def known_split_building_type? ['UNIT'].include?(self) end |
#last_word ⇒ Object
32 33 34 |
# File 'lib/paf/core_ext/string.rb', line 32 def last_word split.last end |
#penultimate_word ⇒ Object
28 29 30 |
# File 'lib/paf/core_ext/string.rb', line 28 def penultimate_word but_last_word.last_word end |
#split_exception? ⇒ Boolean
21 22 23 24 25 26 |
# File 'lib/paf/core_ext/string.rb', line 21 def split_exception? (last_word.exception_i? || last_word.exception_ii?) && /^\d+$/.match(last_word).nil? && !but_last_word.known_building_type? && !penultimate_word.known_split_building_type? end |