Class: Municipitaly2::Province
- Inherits:
-
Object
- Object
- Municipitaly2::Province
- Extended by:
- Forwardable
- Includes:
- DataCaller, RegionDelegator, ZoneDelegator
- Defined in:
- lib/municipitaly2/province.rb
Overview
Define data structure for a Province
Instance Attribute Summary collapse
-
#acronym ⇒ Object
readonly
Returns the value of attribute acronym.
-
#istat ⇒ Object
readonly
Returns the value of attribute istat.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#region_istat ⇒ Object
readonly
Returns the value of attribute region_istat.
Class Method Summary collapse
-
.all ⇒ Object
returns an array of all
Municipitaly2::Provinceobjects.
Instance Method Summary collapse
-
#initialize(region_istat:, name:, istat:, acronym:) ⇒ Province
constructor
A new instance of Province.
-
#iso3166_2 ⇒ Object
(also: #iso3166)
returns ISO 3166-2 code for current province.
-
#municipalities ⇒ Object
returns an array of all
Municipitaly2::Municipalityobjects belongs to current province.
Methods included from ZoneDelegator
Methods included from RegionDelegator
Methods included from DataCaller
Constructor Details
#initialize(region_istat:, name:, istat:, acronym:) ⇒ Province
11 12 13 14 15 16 |
# File 'lib/municipitaly2/province.rb', line 11 def initialize(region_istat:, name:, istat:, acronym:) @region_istat = region_istat @name = name @istat = istat @acronym = acronym end |
Instance Attribute Details
#acronym ⇒ Object (readonly)
Returns the value of attribute acronym.
18 19 20 |
# File 'lib/municipitaly2/province.rb', line 18 def acronym @acronym end |
#istat ⇒ Object (readonly)
Returns the value of attribute istat.
18 19 20 |
# File 'lib/municipitaly2/province.rb', line 18 def istat @istat end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
18 19 20 |
# File 'lib/municipitaly2/province.rb', line 18 def name @name end |
#region_istat ⇒ Object (readonly)
Returns the value of attribute region_istat.
18 19 20 |
# File 'lib/municipitaly2/province.rb', line 18 def region_istat @region_istat end |
Class Method Details
.all ⇒ Object
returns an array of all Municipitaly2::Province objects.
21 22 23 |
# File 'lib/municipitaly2/province.rb', line 21 def self.all data.provinces end |
Instance Method Details
#iso3166_2 ⇒ Object Also known as: iso3166
returns ISO 3166-2 code for current province.
32 33 34 |
# File 'lib/municipitaly2/province.rb', line 32 def iso3166_2 "IT-#{acronym}" end |
#municipalities ⇒ Object
returns an array of all Municipitaly2::Municipality objects belongs to current province.
27 28 29 |
# File 'lib/municipitaly2/province.rb', line 27 def municipalities @municipalities ||= Search.municipalities_from_province_istat(istat) end |