Module: IndianPincodes
- Defined in:
- lib/indian_pincodes.rb
Overview
Returns Details like state name, city name, post office based on pincode.
Constant Summary collapse
- VERSION =
'0.0.1'
Class Method Summary collapse
-
.db ⇒ Object
Find details from yaml file.
-
.load ⇒ Object
Preload yaml file.
-
.search(code) ⇒ Object
Search details from pincode.
Class Method Details
.db ⇒ Object
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.(File.dirname(__FILE__)) india_data = File.join(this_file, 'data/INDIA.yml') YAML.load(File.open(india_data)) end end |
.load ⇒ Object
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 |