Class: MaxMindDB::Result
- Inherits:
-
Object
show all
- Defined in:
- lib/maxminddb/result.rb,
lib/maxminddb/result/postal.rb,
lib/maxminddb/result/traits.rb,
lib/maxminddb/result/location.rb,
lib/maxminddb/result/named_location.rb
Defined Under Namespace
Classes: Location, NamedLocation, Postal, Traits
Instance Method Summary
collapse
Constructor Details
#initialize(raw) ⇒ Result
Returns a new instance of Result.
8
9
10
|
# File 'lib/maxminddb/result.rb', line 8
def initialize(raw)
@raw = raw || {}
end
|
Instance Method Details
#[](attr) ⇒ Object
12
13
14
|
# File 'lib/maxminddb/result.rb', line 12
def [](attr)
raw[attr]
end
|
#city ⇒ Object
16
17
18
|
# File 'lib/maxminddb/result.rb', line 16
def city
@_city ||= NamedLocation.new(raw['city'])
end
|
#connection_type ⇒ Object
56
57
58
|
# File 'lib/maxminddb/result.rb', line 56
def connection_type
@_connection_type ||= raw['connection_type']
end
|
#continent ⇒ Object
20
21
22
|
# File 'lib/maxminddb/result.rb', line 20
def continent
@_continent ||= NamedLocation.new(raw['continent'])
end
|
#country ⇒ Object
24
25
26
|
# File 'lib/maxminddb/result.rb', line 24
def country
@_country ||= NamedLocation.new(raw['country'])
end
|
#found? ⇒ Boolean
28
29
30
|
# File 'lib/maxminddb/result.rb', line 28
def found?
!raw.empty?
end
|
#location ⇒ Object
32
33
34
|
# File 'lib/maxminddb/result.rb', line 32
def location
@_location ||= Location.new(raw['location'])
end
|
#postal ⇒ Object
36
37
38
|
# File 'lib/maxminddb/result.rb', line 36
def postal
@_postal ||= Postal.new(raw['postal'])
end
|
#registered_country ⇒ Object
40
41
42
|
# File 'lib/maxminddb/result.rb', line 40
def registered_country
@_registered_country ||= NamedLocation.new(raw['registered_country'])
end
|
#represented_country ⇒ Object
44
45
46
|
# File 'lib/maxminddb/result.rb', line 44
def represented_country
@_represented_country ||= NamedLocation.new(raw['represented_country'])
end
|
#subdivisions ⇒ Object
48
49
50
|
# File 'lib/maxminddb/result.rb', line 48
def subdivisions
@_subdivisions ||= Array(raw['subdivisions']).map { |hash| NamedLocation.new(hash) }
end
|
#to_hash ⇒ Object
60
61
62
|
# File 'lib/maxminddb/result.rb', line 60
def to_hash
@_to_hash ||= raw.clone
end
|
#traits ⇒ Object
52
53
54
|
# File 'lib/maxminddb/result.rb', line 52
def traits
@_traits ||= Traits.new(raw['traits'])
end
|