Class: CivicInformation::RepresentativesResource::Division

Inherits:
Object
  • Object
show all
Defined in:
lib/civic_information/models/representatives_resource/division.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(open_civic_data_id:, division_json:, parent_resource_id:) ⇒ Division

Returns a new instance of Division.



5
6
7
8
9
10
# File 'lib/civic_information/models/representatives_resource/division.rb', line 5

def initialize(open_civic_data_id:, division_json:, parent_resource_id:)
  @parent_resource_id = parent_resource_id
  @open_civic_data_id = open_civic_data_id
  @also_known_as = division_json['alsoKnownAs'] || []
  @name = division_json['name']
end

Instance Attribute Details

#also_known_asObject

Returns the value of attribute also_known_as.



3
4
5
# File 'lib/civic_information/models/representatives_resource/division.rb', line 3

def also_known_as
  @also_known_as
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/civic_information/models/representatives_resource/division.rb', line 3

def name
  @name
end

#open_civic_data_idObject

Returns the value of attribute open_civic_data_id.



3
4
5
# File 'lib/civic_information/models/representatives_resource/division.rb', line 3

def open_civic_data_id
  @open_civic_data_id
end

Instance Method Details

#officesObject



12
13
14
15
16
# File 'lib/civic_information/models/representatives_resource/division.rb', line 12

def offices
  parent_resource.offices.select do |office|
    office.division_id == open_civic_data_id
  end
end