Module: WorldPostalcodes
- Defined in:
- lib/world_postalcodes.rb
Overview
Returns Details like state name, city name, post office based on pincode.
Constant Summary collapse
- VERSION =
'1.0.0'
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
13 14 15 16 17 18 19 |
# File 'lib/world_postalcodes.rb', line 13 def db @db ||= begin this_file = File.(File.dirname(__FILE__)) data = File.join(this_file, 'data/postal_codes.yml') YAML.load(File.open(data)) end end |
.load ⇒ Object
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 |