Module: WorldPostalcodes

Defined in:
lib/world_postalcodes.rb

Overview

Returns Details like state name, city name, post office based on pincode.

Returns:

  • Details like state name, city name, post office based on pincode.

Constant Summary collapse

VERSION =
'1.0.0'

Class Method Summary collapse

Class Method Details

.dbObject

Find details from yaml file



13
14
15
16
17
18
19
# File 'lib/world_postalcodes.rb', line 13

def db
  @db ||= begin
    this_file = File.expand_path(File.dirname(__FILE__))
    data = File.join(this_file, 'data/postal_codes.yml')
    YAML.load(File.open(data))
  end
end

.loadObject

Preload yaml file



21
22
23
# File 'lib/world_postalcodes.rb', line 21

def load
  db
end

.search(code) ⇒ Object

Search details from pincode



8
9
10
# File 'lib/world_postalcodes.rb', line 8

def search(code)
  db[code]
end