Class: Wettr::IP

Inherits:
Object
  • Object
show all
Defined in:
lib/wettr/ip.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(address:, lat:, lon:) ⇒ IP

Returns a new instance of IP.



4
5
6
# File 'lib/wettr/ip.rb', line 4

def initialize(address:, lat:, lon:)
  @address, @lat, @lon = address, lat, lon
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



2
3
4
# File 'lib/wettr/ip.rb', line 2

def address
  @address
end

#latObject (readonly)

Returns the value of attribute lat.



2
3
4
# File 'lib/wettr/ip.rb', line 2

def lat
  @lat
end

#lonObject (readonly)

Returns the value of attribute lon.



2
3
4
# File 'lib/wettr/ip.rb', line 2

def lon
  @lon
end

Class Method Details

.new_without_ipObject



8
9
10
11
12
# File 'lib/wettr/ip.rb', line 8

def self.new_without_ip
  response = Wettr::IPAPI.call_without_ip
  ip = self.new(address: response["ip"], lat: response["latitude"], lon: response["longitude"])
  ip
end