Sha256: cba561aef8da831c7c7696affd2aff151501bab8349c2d067415f20e9e2bd603
Contents?: true
Size: 1.35 KB
Versions: 4
Compression:
Stored size: 1.35 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, phones: phones - [nil], office_locations: office_locations, 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
4 entries across 4 versions & 1 rubygems