Module: IndianPincodes

Defined in:
lib/indian_pincodes.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 =
'0.0.1'

Class Method Summary collapse

Class Method Details

.dbObject

Find details from yaml file



11
12
13
14
15
16
17
# File 'lib/indian_pincodes.rb', line 11

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

.loadObject

Preload yaml file



19
20
21
# File 'lib/indian_pincodes.rb', line 19

def load
  db
end

.search(code) ⇒ Object

Search details from pincode



7
8
9
# File 'lib/indian_pincodes.rb', line 7

def search(code)
  db[code]
end