Class: CivicInformation::RepresentativesResource::Official

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result_index:, official_json:, parent_resource_id:) ⇒ Official

Returns a new instance of Official.



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/civic_information/models/representatives_resource/official.rb', line 6

def initialize(result_index:, official_json:, parent_resource_id:)
  @parent_resource_id = parent_resource_id
  @result_index = result_index
  @name = official_json["name"]
  @photo_url = official_json["photoUrl"]
  @party = official_json["party"]
  @phones = official_json["phones"] || []
  @emails = official_json["emails"] || []
  @urls = official_json["urls"] || []
  @channels = build_channels(official_json["channels"] || [])
  @addresses = build_addresses(official_json["address"] || [])
end

Instance Attribute Details

#addressesObject

Returns the value of attribute addresses.



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

def addresses
  @addresses
end

#channelsObject

Returns the value of attribute channels.



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

def channels
  @channels
end

#emailsObject

Returns the value of attribute emails.



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

def emails
  @emails
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#partyObject

Returns the value of attribute party.



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

def party
  @party
end

#phonesObject

Returns the value of attribute phones.



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

def phones
  @phones
end

#photo_urlObject

Returns the value of attribute photo_url.



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

def photo_url
  @photo_url
end

#result_indexObject

Returns the value of attribute result_index.



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

def result_index
  @result_index
end

#urlsObject

Returns the value of attribute urls.



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

def urls
  @urls
end

Instance Method Details

#officesObject



19
20
21
22
23
# File 'lib/civic_information/models/representatives_resource/official.rb', line 19

def offices
  parent_resource.offices.select do |office|
    office.official_indices.include? result_index
  end
end