Class: MaxMindDB::Result

Inherits:
Object
  • 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/subdivisions.rb,
lib/maxminddb/result/named_location.rb

Defined Under Namespace

Classes: Location, NamedLocation, Postal, Subdivisions, Traits

Instance Method Summary collapse

Constructor Details

#initialize(raw) ⇒ Result

Returns a new instance of Result.



9
10
11
# File 'lib/maxminddb/result.rb', line 9

def initialize(raw)
  @raw = raw || {}
end

Instance Method Details

#[](attr) ⇒ Object



13
14
15
# File 'lib/maxminddb/result.rb', line 13

def [](attr)
  raw[attr]
end

#cityObject



17
18
19
# File 'lib/maxminddb/result.rb', line 17

def city
  @_city ||= NamedLocation.new(raw['city'])
end

#connection_typeObject



57
58
59
# File 'lib/maxminddb/result.rb', line 57

def connection_type
  @_connection_type ||= raw['connection_type']
end

#continentObject



21
22
23
# File 'lib/maxminddb/result.rb', line 21

def continent
  @_continent ||= NamedLocation.new(raw['continent'])
end

#countryObject



25
26
27
# File 'lib/maxminddb/result.rb', line 25

def country
  @_country ||= NamedLocation.new(raw['country'])
end

#found?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/maxminddb/result.rb', line 29

def found?
  !raw.empty?
end

#locationObject



33
34
35
# File 'lib/maxminddb/result.rb', line 33

def location
  @_location ||= Location.new(raw['location'])
end

#networkObject



61
62
63
# File 'lib/maxminddb/result.rb', line 61

def network
  @_network ||= raw['network']
end

#postalObject



37
38
39
# File 'lib/maxminddb/result.rb', line 37

def postal
  @_postal ||= Postal.new(raw['postal'])
end

#registered_countryObject



41
42
43
# File 'lib/maxminddb/result.rb', line 41

def registered_country
  @_registered_country ||= NamedLocation.new(raw['registered_country'])
end

#represented_countryObject



45
46
47
# File 'lib/maxminddb/result.rb', line 45

def represented_country
  @_represented_country ||= NamedLocation.new(raw['represented_country'])
end

#subdivisionsObject



49
50
51
# File 'lib/maxminddb/result.rb', line 49

def subdivisions
  @_subdivisions ||= Subdivisions.new(raw['subdivisions'])
end

#to_hashObject



65
66
67
# File 'lib/maxminddb/result.rb', line 65

def to_hash
  @_to_hash ||= raw.clone
end

#traitsObject



53
54
55
# File 'lib/maxminddb/result.rb', line 53

def traits
  @_traits ||= Traits.new(raw['traits'])
end