Locations NG is a gem that provides methods to get all states, their cities and LGAs in Nigeria.
-
Rails version
>= 4.2.6
-
Ruby version
>= 2.3.1
Add this line to your Gemfile
gem 'locations_ng'
And then execute:
$ bundle install
Or install it yourself
$ gem install locations_ng
require 'locations_ng'
LocationsNg::State.all
[
{:name=>"Abia", :capital=>"Umuahia"},
{:name=>"Adamawa", :capital=>"Yola"},
{:name=>"Akwa Ibom", :capital=>"Uyo"},
...
...
{:name=>"Zamfara",:capital=>"Gusau"}
]
LocationsNg::State.details('Lagos')
{'minLat'=>6.3936419,
'name'=>'Lagos',
'capital'=>'Ikeja',
'latitude'=>6.5243793,
'minLong'=>3.0982732,
'maxLat'=>6.7027984,
'longitude'=>3.3792057,
'maxLong'=>3.696727799999999,
'alias'=>'lagos',
'area'=>3345
'cities'=>['Agege', 'Ikeja'],
'lgas'=>['Agege', 'Ajeromi-Ifelodun', 'Alimosho',
'Amuwo-Odofin', 'Badagry', 'Apapa', 'Epe',
'Eti Osa', 'Ibeju-Lekki', 'Ifako-Ijaiye',
'Ikeja', 'Ikorodu', 'Kosofe', 'Lagos Island',
'Mushin', 'Lagos Mainland', 'Ojo', 'Oshodi-Isolo',
'Shomolu', 'Surulere Lagos State']
}
LocationsNg::State.capital('Lagos')
Ikeja
LocationsNg::City.all
[
{
"state":"Akwa Ibom",
"alias":"akwa_ibom",
"cities":["Eket", "Ikot Ekpene", "Oron", "Uyo"]
},
{
"state":"Bauchi",
"alias":"bauchi",
"cities":["Bauchi"]
},
...
...
{
"state":"Zamfara",
"alias":"zamfara",
"cities":["Gusau"]
}
]
LocationsNg::City.cities('Akwa Ibom')
['Eket', 'Ikot Ekpene', 'Oron', 'Uyo']
LocationsNg::Lga.all
[
{
"state"=>"Adamawa",
"alias"=>"adamawa",
"lgas"=>[
"Demsa",
"Fufure",
"Ganye",
"Gayuk",
"Gombi",
"Grie",
"Hong",
"Jada",
"Larmurde",
"Madagali",
"Maiha",
"Mayo Belwa",
"Michika",
"Mubi North",
"Mubi South",
"Numan",
"Shelleng",
"Song",
"Toungo",
"Yola North",
"Yola South"
]
},
...
...
{
"state"=>"Abia",
"alias"=>"abia",
"lgas"=>[
"Aba North",
"Arochukwu",
"Aba South",
"Bende",
"Isiala Ngwa North",
"Ikwuano",
"Isiala Ngwa South",
"Isuikwuato",
"Obi Ngwa",
"Ohafia",
"Osisioma",
"Ugwunagbo",
"Ukwa East",
"Ukwa West",
"Umuahia North",
"Umuahia South",
"Umu Nneochi"
]
}
]
LocationsNg::Lga.lgas('Lagos')
['Agege', 'Ajeromi-Ifelodun', 'Alimosho',
'Amuwo-Odofin', 'Badagry', 'Apapa', 'Epe',
'Eti Osa', 'Ibeju-Lekki', 'Ifako-Ijaiye',
'Ikeja', 'Ikorodu', 'Kosofe', 'Lagos Island',
'Mushin', 'Lagos Mainland', 'Ojo', 'Oshodi-Isolo',
'Shomolu', 'Surulere Lagos State']
LocationsNg::Lga.localities('Abia', 'Aba North')
['Ariaria', 'Asaokpoja', 'Asaokpulor',
'Eziama ward', 'Industrial', 'Ogbor 1',
'Ogbor 2', 'Old GRA', 'Osusu 1', 'Osusu 2',
'St. Eugene', 'Umuogor', 'Umuola', 'Uratta']
- Fork this repository and clone locally.
- Create an upstream remote and sync your local copy before you branch.
- Branch for each separate piece of work.
- Push to your origin repository.
- Create a new Pull Request, ensure that the "base fork" points to the correct repository and branch.
MIT