Class: Maxmind::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/maxmind/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response = nil) ⇒ Response

Returns a new instance of Response.

Raises:

  • (ArgumentError)


12
13
14
15
16
# File 'lib/maxmind/response.rb', line 12

def initialize(response = nil)
  raise ArgumentError, 'need a valid response string' if response.nil?

  parse(response)
end

Instance Attribute Details

#anonymous_proxyObject Also known as: anonymous_proxy?

Returns the value of attribute anonymous_proxy.



3
4
5
# File 'lib/maxmind/response.rb', line 3

def anonymous_proxy
  @anonymous_proxy
end

#bin_countryObject

Returns the value of attribute bin_country.



3
4
5
# File 'lib/maxmind/response.rb', line 3

def bin_country
  @bin_country
end

#bin_matchObject Also known as: bin_match?

Returns the value of attribute bin_match.



3
4
5
# File 'lib/maxmind/response.rb', line 3

def bin_match
  @bin_match
end

#bin_nameObject

Returns the value of attribute bin_name.



3
4
5
# File 'lib/maxmind/response.rb', line 3

def bin_name
  @bin_name
end

#bin_name_matchObject

Returns the value of attribute bin_name_match.



3
4
5
# File 'lib/maxmind/response.rb', line 3

def bin_name_match
  @bin_name_match
end

#bin_phoneObject

Returns the value of attribute bin_phone.



3
4
5
# File 'lib/maxmind/response.rb', line 3

def bin_phone
  @bin_phone
end

#bin_phone_matchObject

Returns the value of attribute bin_phone_match.



3
4
5
# File 'lib/maxmind/response.rb', line 3

def bin_phone_match
  @bin_phone_match
end

#carder_emailObject Also known as: carder_email?

Returns the value of attribute carder_email.



3
4
5
# File 'lib/maxmind/response.rb', line 3

def carder_email
  @carder_email
end

#city_postal_matchObject Also known as: city_postal_match?

Returns the value of attribute city_postal_match.



3
4
5
# File 'lib/maxmind/response.rb', line 3

def city_postal_match
  @city_postal_match
end

#country_codeObject

Returns the value of attribute country_code.



3
4
5
# File 'lib/maxmind/response.rb', line 3

def country_code
  @country_code
end

#country_matchObject Also known as: country_match?

Returns the value of attribute country_match.



3
4
5
# File 'lib/maxmind/response.rb', line 3

def country_match
  @country_match
end

#distanceObject

Returns the value of attribute distance.



3
4
5
# File 'lib/maxmind/response.rb', line 3

def distance
  @distance
end

#errorObject

Returns the value of attribute error.



3
4
5
# File 'lib/maxmind/response.rb', line 3

def error
  @error
end

#explanationObject

Returns the value of attribute explanation.



3
4
5
# File 'lib/maxmind/response.rb', line 3

def explanation
  @explanation
end

#free_mailObject Also known as: free_mail?

Returns the value of attribute free_mail.



3
4
5
# File 'lib/maxmind/response.rb', line 3

def free_mail
  @free_mail
end

#high_risk_countryObject Also known as: high_risk_country?

Returns the value of attribute high_risk_country.



3
4
5
# File 'lib/maxmind/response.rb', line 3

def high_risk_country
  @high_risk_country
end

#high_risk_passwordObject Also known as: high_risk_password?

Returns the value of attribute high_risk_password.



3
4
5
# File 'lib/maxmind/response.rb', line 3

def high_risk_password
  @high_risk_password
end

#high_risk_usernameObject Also known as: high_risk_username?

Returns the value of attribute high_risk_username.



3
4
5
# File 'lib/maxmind/response.rb', line 3

def high_risk_username
  @high_risk_username
end

#ip_cityObject

Returns the value of attribute ip_city.



3
4
5
# File 'lib/maxmind/response.rb', line 3

def ip_city
  @ip_city
end

#ip_ispObject

Returns the value of attribute ip_isp.



3
4
5
# File 'lib/maxmind/response.rb', line 3

def ip_isp
  @ip_isp
end

#ip_latitudeObject

Returns the value of attribute ip_latitude.



3
4
5
# File 'lib/maxmind/response.rb', line 3

def ip_latitude
  @ip_latitude
end

#ip_longitudeObject

Returns the value of attribute ip_longitude.



3
4
5
# File 'lib/maxmind/response.rb', line 3

def ip_longitude
  @ip_longitude
end

#ip_orgObject

Returns the value of attribute ip_org.



3
4
5
# File 'lib/maxmind/response.rb', line 3

def ip_org
  @ip_org
end

#ip_regionObject

Returns the value of attribute ip_region.



3
4
5
# File 'lib/maxmind/response.rb', line 3

def ip_region
  @ip_region
end

#is_transparent_proxyObject Also known as: is_transparent_proxy?

Returns the value of attribute is_transparent_proxy.



3
4
5
# File 'lib/maxmind/response.rb', line 3

def is_transparent_proxy
  @is_transparent_proxy
end

#maxmind_idObject

Returns the value of attribute maxmind_id.



3
4
5
# File 'lib/maxmind/response.rb', line 3

def maxmind_id
  @maxmind_id
end

#phone_in_billing_locationObject

Returns the value of attribute phone_in_billing_location.



3
4
5
# File 'lib/maxmind/response.rb', line 3

def phone_in_billing_location
  @phone_in_billing_location
end

#proxy_scoreObject

Returns the value of attribute proxy_score.



3
4
5
# File 'lib/maxmind/response.rb', line 3

def proxy_score
  @proxy_score
end

#queries_remainingObject

Returns the value of attribute queries_remaining.



3
4
5
# File 'lib/maxmind/response.rb', line 3

def queries_remaining
  @queries_remaining
end

#responseObject

Returns the value of attribute response.



3
4
5
# File 'lib/maxmind/response.rb', line 3

def response
  @response
end

#risk_scoreObject

Returns the value of attribute risk_score.



3
4
5
# File 'lib/maxmind/response.rb', line 3

def risk_score
  @risk_score
end

#scoreObject

Returns the value of attribute score.



3
4
5
# File 'lib/maxmind/response.rb', line 3

def score
  @score
end

#ship_city_postal_matchObject Also known as: ship_city_postal_match?

Returns the value of attribute ship_city_postal_match.



3
4
5
# File 'lib/maxmind/response.rb', line 3

def ship_city_postal_match
  @ship_city_postal_match
end

#ship_forwardObject

Returns the value of attribute ship_forward.



3
4
5
# File 'lib/maxmind/response.rb', line 3

def ship_forward
  @ship_forward
end

Instance Method Details

#parse(response) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/maxmind/response.rb', line 18

def parse(response)
  response.split(';').each do |parameter|
    k, v = parameter.split('=')
  
    case k
    when 'err'
      set_attribute('error', v)
    when 'custPhoneInBillingLoc'
      set_attribute('phone_in_billing_location', v)
    when 'maxmindID'
      set_attribute('maxmind_id', v)
    when 'isTransProxy'
      set_attribute('is_transparent_proxy', v)
    when 'explanation'
      @explanation = v
    else
      set_attribute(k.gsub(/([A-Z])/, '_\1').downcase, v)
    end
  end
end