Class: CivicInformation::RepresentativesResource::Office
- Inherits:
-
Object
- Object
- CivicInformation::RepresentativesResource::Office
- Defined in:
- lib/civic_information/models/representatives_resource/office.rb
Instance Attribute Summary collapse
-
#division_id ⇒ Object
Returns the value of attribute division_id.
-
#levels ⇒ Object
Returns the value of attribute levels.
-
#name ⇒ Object
Returns the value of attribute name.
-
#official_indices ⇒ Object
Returns the value of attribute official_indices.
-
#result_index ⇒ Object
Returns the value of attribute result_index.
-
#roles ⇒ Object
Returns the value of attribute roles.
-
#sources ⇒ Object
Returns the value of attribute sources.
Instance Method Summary collapse
- #division ⇒ Object
-
#initialize(result_index:, office_json:, parent_resource_id:) ⇒ Office
constructor
A new instance of Office.
- #officials ⇒ Object
Constructor Details
#initialize(result_index:, office_json:, parent_resource_id:) ⇒ Office
Returns a new instance of Office.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/civic_information/models/representatives_resource/office.rb', line 6 def initialize(result_index:, office_json:, parent_resource_id:) @parent_resource_id = parent_resource_id @result_index = result_index @division_id = office_json['divisionId'] @levels = office_json['levels'] || [] @name = office_json['name'] @roles = office_json['roles'] || [] @sources = office_json['sources'] || [] @official_indices = office_json['officialIndices'] || [] end |
Instance Attribute Details
#division_id ⇒ Object
Returns the value of attribute division_id.
3 4 5 |
# File 'lib/civic_information/models/representatives_resource/office.rb', line 3 def division_id @division_id end |
#levels ⇒ Object
Returns the value of attribute levels.
3 4 5 |
# File 'lib/civic_information/models/representatives_resource/office.rb', line 3 def levels @levels end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/civic_information/models/representatives_resource/office.rb', line 3 def name @name end |
#official_indices ⇒ Object
Returns the value of attribute official_indices.
3 4 5 |
# File 'lib/civic_information/models/representatives_resource/office.rb', line 3 def official_indices @official_indices end |
#result_index ⇒ Object
Returns the value of attribute result_index.
3 4 5 |
# File 'lib/civic_information/models/representatives_resource/office.rb', line 3 def result_index @result_index end |
#roles ⇒ Object
Returns the value of attribute roles.
3 4 5 |
# File 'lib/civic_information/models/representatives_resource/office.rb', line 3 def roles @roles end |
#sources ⇒ Object
Returns the value of attribute sources.
3 4 5 |
# File 'lib/civic_information/models/representatives_resource/office.rb', line 3 def sources @sources end |
Instance Method Details
#division ⇒ Object
23 24 25 26 27 |
# File 'lib/civic_information/models/representatives_resource/office.rb', line 23 def division parent_resource.divisions.find do |division| division.open_civic_data_id == division_id end end |
#officials ⇒ Object
17 18 19 20 21 |
# File 'lib/civic_information/models/representatives_resource/office.rb', line 17 def officials parent_resource.officials.select do |official| @official_indices.include? official.result_index end end |