Class: Municipitaly2::Zone
- Inherits:
-
Object
- Object
- Municipitaly2::Zone
- Includes:
- DataCaller
- Defined in:
- lib/municipitaly2/zone.rb
Overview
Define data structure for a Zone
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
-
.all ⇒ Object
returns an array of all
Municipitaly2::Zoneobjects.
Instance Method Summary collapse
-
#initialize(name:, code:) ⇒ Zone
constructor
A new instance of Zone.
-
#municipalities ⇒ Object
returns an array of all
Municipitaly2::Municipalityobjects belongs to current zone. -
#provinces ⇒ Object
returns an array of all
Municipitaly2::Provinceobjects belongs to current zone. -
#regions ⇒ Object
returns an array of all
Municipitaly2::Regionobjects belongs to current zone.
Methods included from DataCaller
Constructor Details
#initialize(name:, code:) ⇒ Zone
Returns a new instance of Zone.
8 9 10 11 |
# File 'lib/municipitaly2/zone.rb', line 8 def initialize(name:, code:) @name = name @code = code end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
13 14 15 |
# File 'lib/municipitaly2/zone.rb', line 13 def code @code end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
13 14 15 |
# File 'lib/municipitaly2/zone.rb', line 13 def name @name end |
Class Method Details
.all ⇒ Object
returns an array of all Municipitaly2::Zone objects.
16 17 18 |
# File 'lib/municipitaly2/zone.rb', line 16 def self.all data.zones end |
Instance Method Details
#municipalities ⇒ Object
returns an array of all Municipitaly2::Municipality objects belongs to current zone.
34 35 36 |
# File 'lib/municipitaly2/zone.rb', line 34 def municipalities @municipalities ||= Search.municipalities_from_zone_code(code) end |
#provinces ⇒ Object
returns an array of all Municipitaly2::Province objects belongs to current zone.
28 29 30 |
# File 'lib/municipitaly2/zone.rb', line 28 def provinces @provinces ||= Search.provinces_from_zone_code(code) end |
#regions ⇒ Object
returns an array of all Municipitaly2::Region objects belongs to current zone.
22 23 24 |
# File 'lib/municipitaly2/zone.rb', line 22 def regions Search.regions_from_zone_code(code) end |