hackedunit-maxmind 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.3.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{hackedunit-maxmind}
8
- s.version = "0.2.0"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Adam Daniels", "Tinu Cleatus"]
12
- s.date = %q{2010-02-10}
12
+ s.date = %q{2010-02-22}
13
13
  s.email = %q{tinu@tinucleatus.com}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
@@ -13,6 +13,15 @@ module Maxmind
13
13
  raise ArgumentError, 'need a valid response string' if response.nil?
14
14
 
15
15
  parse(response)
16
+ @attributes = attributes_from_response
17
+ end
18
+
19
+ def attributes_from_response
20
+ hash_to_return = {}
21
+ self.instance_variables.each do |var|
22
+ hash_to_return[var.gsub("@","")] = self.instance_variable_get(var)
23
+ end
24
+ return hash_to_return
16
25
  end
17
26
 
18
27
  def parse(response)
@@ -47,6 +56,29 @@ module Maxmind
47
56
  alias_method :city_postal_match?, :city_postal_match
48
57
  alias_method :ship_city_postal_match?, :ship_city_postal_match
49
58
  alias_method :bin_match?, :bin_match
59
+
60
+ # Returns an array of names for the attributes available on this object sorted alphabetically.
61
+ def attribute_names
62
+ @attributes.keys.sort
63
+ end
64
+
65
+ # Returns a hash of all the attributes with their names as keys and the values of the attributes as values.
66
+ def attributes
67
+ attrs = self.attribute_names.inject({}) do |attrs, name|
68
+ attrs[name] = read_attribute(name)
69
+ attrs
70
+ end
71
+ attrs.symbolize_keys
72
+ end
73
+
74
+ def read_attribute(attr_name)
75
+ attr_name = attr_name.to_s
76
+ if !(value = @attributes[attr_name]).nil?
77
+ value
78
+ else
79
+ nil
80
+ end
81
+ end
50
82
 
51
83
  protected
52
84
  def set_attribute(k, v)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hackedunit-maxmind
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Daniels
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2010-02-10 00:00:00 +05:30
13
+ date: 2010-02-22 00:00:00 +05:30
14
14
  default_executable:
15
15
  dependencies: []
16
16