Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for continents and their structure #176

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ tmp
.bundle/*
Gemfile.lock
.rvmrc
.ruby-gemset
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,40 @@ Some subregions may contain additional subregions. An example of this is Spain:
andalucia.subregions.first
=> <#Carmen::Region name="Almería" type="province">

If you need structural data about the continents. You can start here:

Carmen::World.continents

This will return a `Carmen::Continent` that you can use like this:

continent = Carmen::World.continents.first
sub_continents = continent.sub_continents

To get the sub-continents of a given continent. Might be empty.

countries = continent.countries

This will give you **all countries** contained in a given continent. This will also give you countries that might be contained in sub_continents. Meaning `world.countries` will give you all countries of the world.

Here are some examples:

Carmen::Continent.coded('150')
=> #<Carmen::Continent:0x007fb78b154858 @code="150", @contains=["154", "155", "151", "039"], @parent=nil>

Carmen::Continent.coded('150').name
=> "Europe"

Carmen::Continent.coded('150').sub_continents.map { |c| c.name }
=> ["Northern Europe", "Western Europe", "Eastern Europe", "Southern Europe"]

Of course you can also get the continent of a country be trying:

Carmen::Country.coded('DE')
=> <#Carmen::Country name="Germany">

Carmen::Country.coded('DE').continent.name
=> "Western Europe"

## How Carmen organizes data

In order to facilitate support for I18n, Carmen stores the structure of regions
Expand Down
1 change: 0 additions & 1 deletion carmen.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ Gem::Specification.new do |s|
s.files = Dir.glob("{lib,iso_data,locale}/**/*") + %w(MIT-LICENSE README.md CHANGELOG.md)

s.add_development_dependency('minitest', ["= 2.6.1"])
s.add_development_dependency('nokogiri')
s.add_development_dependency('rake', '0.9.2.2')
s.add_development_dependency('i18n')
s.add_dependency('activesupport', '>= 3.0.0')
Expand Down
Loading