Class: Geolocation

Inherits:
Object
  • Object
show all
Defined in:
lib/ipgeolocation_io/Geolocation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ Geolocation

Returns a new instance of Geolocation.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/ipgeolocation_io/Geolocation.rb', line 32

def initialize(json)
  @status = json["status"].to_i;
  if @status != 200 || json["message"] != nil
    @message = json["message"].to_s;
  else
    @ip = json["ip"];
    @continentCode = json["continent_code"];
    @continentName = json["continent_name"];
    @countryCode2 = json["country_code2"];
    @countryCode3 = json["country_code3"];
    @countryName = json["country_name"];
    @countryCapital = json["country_capital"];
    @stateProvince = json["state_prov"];
    @district = json["district"];
    @city = json["city"];
    @zipcode = json["zipcode"];
    @latitude = json["latitude"];
    @longitude = json["longitude"];
    @isEU = json["is_eu"];
    @callingCode = json["calling_code"];
    @countryTLD = json["country_tld"];
    @languages = json["languages"];
    @countryFlag = json["country_flag"];
    @isp = json["isp"];
    @connectionType = json["connection_type"];
    @organization = json["organization"];
    @geonameID = json["geoname_id"];
    if(json["currency"] != nil)
      @currency = GeolocationCurrency.new(json["currency"]);
    end
    if(json["time_zone"] != nil)
      @timezone = GeolocationTimezone.new(json["time_zone"]);
    end
  end
end

Instance Attribute Details

#callingCodeObject (readonly)

Returns the value of attribute callingCode.



21
22
23
# File 'lib/ipgeolocation_io/Geolocation.rb', line 21

def callingCode
  @callingCode
end

#cityObject (readonly)

Returns the value of attribute city.



16
17
18
# File 'lib/ipgeolocation_io/Geolocation.rb', line 16

def city
  @city
end

#connectionTypeObject (readonly)

Returns the value of attribute connectionType.



26
27
28
# File 'lib/ipgeolocation_io/Geolocation.rb', line 26

def connectionType
  @connectionType
end

#continentCodeObject (readonly)

Returns the value of attribute continentCode.



8
9
10
# File 'lib/ipgeolocation_io/Geolocation.rb', line 8

def continentCode
  @continentCode
end

#continentNameObject (readonly)

Returns the value of attribute continentName.



9
10
11
# File 'lib/ipgeolocation_io/Geolocation.rb', line 9

def continentName
  @continentName
end

#countryCapitalObject (readonly)

Returns the value of attribute countryCapital.



13
14
15
# File 'lib/ipgeolocation_io/Geolocation.rb', line 13

def countryCapital
  @countryCapital
end

#countryCode2Object (readonly)

Returns the value of attribute countryCode2.



10
11
12
# File 'lib/ipgeolocation_io/Geolocation.rb', line 10

def countryCode2
  @countryCode2
end

#countryCode3Object (readonly)

Returns the value of attribute countryCode3.



11
12
13
# File 'lib/ipgeolocation_io/Geolocation.rb', line 11

def countryCode3
  @countryCode3
end

#countryFlagObject (readonly)

Returns the value of attribute countryFlag.



24
25
26
# File 'lib/ipgeolocation_io/Geolocation.rb', line 24

def countryFlag
  @countryFlag
end

#countryNameObject (readonly)

Returns the value of attribute countryName.



12
13
14
# File 'lib/ipgeolocation_io/Geolocation.rb', line 12

def countryName
  @countryName
end

#countryTLDObject (readonly)

Returns the value of attribute countryTLD.



22
23
24
# File 'lib/ipgeolocation_io/Geolocation.rb', line 22

def countryTLD
  @countryTLD
end

#currencyObject (readonly)

Returns the value of attribute currency.



29
30
31
# File 'lib/ipgeolocation_io/Geolocation.rb', line 29

def currency
  @currency
end

#districtObject (readonly)

Returns the value of attribute district.



15
16
17
# File 'lib/ipgeolocation_io/Geolocation.rb', line 15

def district
  @district
end

#geonameIDObject (readonly)

Returns the value of attribute geonameID.



28
29
30
# File 'lib/ipgeolocation_io/Geolocation.rb', line 28

def geonameID
  @geonameID
end

#ipObject (readonly)

Returns the value of attribute ip.



7
8
9
# File 'lib/ipgeolocation_io/Geolocation.rb', line 7

def ip
  @ip
end

#isEUObject (readonly)

Returns the value of attribute isEU.



20
21
22
# File 'lib/ipgeolocation_io/Geolocation.rb', line 20

def isEU
  @isEU
end

#ispObject (readonly)

Returns the value of attribute isp.



25
26
27
# File 'lib/ipgeolocation_io/Geolocation.rb', line 25

def isp
  @isp
end

#languagesObject (readonly)

Returns the value of attribute languages.



23
24
25
# File 'lib/ipgeolocation_io/Geolocation.rb', line 23

def languages
  @languages
end

#latitudeObject (readonly)

Returns the value of attribute latitude.



18
19
20
# File 'lib/ipgeolocation_io/Geolocation.rb', line 18

def latitude
  @latitude
end

#longitudeObject (readonly)

Returns the value of attribute longitude.



19
20
21
# File 'lib/ipgeolocation_io/Geolocation.rb', line 19

def longitude
  @longitude
end

#messageObject (readonly)

Returns the value of attribute message.



6
7
8
# File 'lib/ipgeolocation_io/Geolocation.rb', line 6

def message
  @message
end

#organizationObject (readonly)

Returns the value of attribute organization.



27
28
29
# File 'lib/ipgeolocation_io/Geolocation.rb', line 27

def organization
  @organization
end

#stateProvinceObject (readonly)

Returns the value of attribute stateProvince.



14
15
16
# File 'lib/ipgeolocation_io/Geolocation.rb', line 14

def stateProvince
  @stateProvince
end

#statusObject (readonly)

Returns the value of attribute status.



5
6
7
# File 'lib/ipgeolocation_io/Geolocation.rb', line 5

def status
  @status
end

#timezoneObject (readonly)

Returns the value of attribute timezone.



30
31
32
# File 'lib/ipgeolocation_io/Geolocation.rb', line 30

def timezone
  @timezone
end

#zipCodeObject (readonly)

Returns the value of attribute zipCode.



17
18
19
# File 'lib/ipgeolocation_io/Geolocation.rb', line 17

def zipCode
  @zipCode
end