Skip to content

Commit

Permalink
continents added to carmen
Browse files Browse the repository at this point in the history
  • Loading branch information
dpaluy committed Sep 3, 2020
1 parent e56f10d commit 12631b4
Show file tree
Hide file tree
Showing 15 changed files with 1,142 additions and 359 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
rvm:
- 2.4.0
- 2.5.0
- 2.6.0
- 2.7.0
- ruby-head
before_install:
- gem install bundler
Expand Down
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,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
Loading

0 comments on commit 12631b4

Please sign in to comment.