Sha256: fbb97f29a4221be375ac48a0212b2eca6615ac296e4b3ced7db4d72f098cffd5

Contents?: true

Size: 633 Bytes

Versions: 4

Compression:

Stored size: 633 Bytes

Contents

module MaxMind
  class CityService < Service

    self.base_path = '/b'

    def parsed_response
      if self.valid_response?
        parsed_response = CSV.parse_line(self.response)
        {
          :country => parsed_response[0],
          :state => parsed_response[1],
          :city => parsed_response[2],
          :latitude => parsed_response[3],
          :longitude => parsed_response[4],
          :api_response => self.response
        }
      else
        {
          :api_response => self.response
        }
      end
    end

    def valid_response?
      super && !(self.response =~ /,,,,,(.+?)/)
    end

  end
end

Version data entries

4 entries across 4 versions & 3 rubygems

Version Path
crushlovely-max_mind-1.0.0 lib/max_mind/service/city.rb
heythisisnate-max_mind-0.1.0 lib/max_mind/service/city.rb
heythisisnate-max_mind-0.1.1 lib/max_mind/service/city.rb
max_mind-1.0.0 lib/max_mind/service/city.rb