Class: Carmen::RegionCollection
- Inherits:
-
Array
- Object
- Array
- Carmen::RegionCollection
- Includes:
- Querying
- Defined in:
- lib/carmen/region_collection.rb
Overview
RegionCollection is responsible for holding the subregions for a region and also provides an interface to query said subregions.
Example:
states = Carmen::Country.coded('US').subregions
=> #<RegionCollection>
states.size
=> 5
states.named('Illinois')
=> #<Region name:"Illinois" code: "IL">
Instance Method Summary collapse
-
#typed(type) ⇒ Object
Filters the regions in this collection by type.
Methods included from Querying
Instance Method Details
#typed(type) ⇒ Object
Filters the regions in this collection by type.
type - The String type to filter by
Returns a region collection containing all the regions with the supplied type.
25 26 27 28 29 |
# File 'lib/carmen/region_collection.rb', line 25 def typed(type) downcased_type = type.downcase results = select{ |r| r.type == downcased_type } Carmen::RegionCollection.new(results) end |