Class: PC4

Inherits:
Object show all
Defined in:
lib/xdata/postcodes_4.rb

Constant Summary collapse

@@pc =
Marshal.load(Zlib::GzipReader.new(StringIO.new(data)).read)

Class Method Summary collapse

Class Method Details

.lookup(str) ⇒ Object



10
11
12
13
14
15
# File 'lib/xdata/postcodes_4.rb', line 10

def self.lookup(str)
  str = str.gsub(/[^\d]/,'')[0..3]
  bbox = @@pc[str]
  return [[bbox[0][0].unpack('e')[0], bbox[0][1].unpack('e')[0]],[bbox[1][0].unpack('e')[0], bbox[1][1].unpack('e')[0]]] if bbox
  nil
end