Sha256: bfd5439e8d67074c03394bc8aedc22476e4c3b81af55e7a9d9875774d985d658
Contents?: true
Size: 1.37 KB
Versions: 2
Compression:
Stored size: 1.37 KB
Contents
# frozen_string_literal: true require_relative './base' module GetYourRep # Parses rep information from Open States responses. class OpenStatesRep < Base # These attributes hold arrays of information, and are empty arrays by default. attr_reader :email, :phones def initialize(options = {}) # :nodoc: super @email = [] @phones = [] end # Build a hash from attributes to be passed to # the GetYourRep::Representative constructor method. # def build_hash { name: full_name.split(', ').reverse.join(' '), office: office, party: party, office_locations: office_locations, phones: phones - [nil], email: email - [nil], url: url, photo: photo_url, committees: committees } end private def office "#{state.upcase} #{chamber.capitalize} Chamber, #{district}" end def office_locations offices.map do |office| location = OpenStatesOffice.new(office) @email << office['email'] @phones << office['phone'] office_hash = location.build_hash OfficeLocation.new(office_hash) end end # Parses committee involvement. def committees roles.map { |role| role['committee'] } - [nil] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
get_your_rep-1.2.0 | lib/get_your_rep/responses/open_states_rep.rb |
get_your_rep-1.1.1 | lib/get_your_rep/responses/open_states_rep.rb |