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

continents added to carmen #1

Merged
merged 1 commit into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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