Sha256: c13acf8f7448813c30d41f72823a76fc4ee6d1c41c7be0a3e0e9e34d0a9253d4
Contents?: true
Size: 1.01 KB
Versions: 2
Compression:
Stored size: 1.01 KB
Contents
# frozen_string_literal: true require_relative './base' module GetYourRep # Parses office location information from a Google response. class GoogleOffice < Base # These attributes are defined so they can be called even # if they are not defined during initialization. attr_accessor :line1, :line2 # Builds the hash to pass as constructor options for a new OfficeLocation. def build_hash office_hash = {} office_hash[:type] = determine_office_type office_hash[:line_1] = line1 office_hash[:line_2] = line2 office_hash[:city] = city.capitalize office_hash[:state] = state.upcase office_hash[:zip] = zip office_hash end private def determine_office_type # rubocop:disable Metrics/LineLength matches = /(state|house|senate|assembly|capitol|dirksen|reyburn|rayburn|legislative|legislature|government)+/ if line1.downcase =~ matches 'capitol' else 'district' end 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/google_office.rb |
get_your_rep-1.1.1 | lib/get_your_rep/responses/google_office.rb |