Method: OpenWeatherClient::Weather#initialize

Defined in:
lib/open_weather_client/weather.rb

#initialize(lat:, lon:, time: Time.now) ⇒ Weather

Initialize a new Weather request

Parameters:

  • lat (Float)

    latitude of the requests location

  • lon (Float)

    longitude of the requests location

  • time (Time) (defaults to: Time.now)

    time of the request

Raises:

  • (RangeError)

    if one lat or lon are out of the expected ranges



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/open_weather_client/weather.rb', line 22

def initialize(lat:, lon:, time: Time.now)
  if OpenWeatherClient.configuration.spatial_quantization.respond_to?(:call)
    lat, lon = OpenWeatherClient.configuration.spatial_quantization.call(lat, lon)
  end

  raise RangeError unless (-90..90).member?(lat)
  raise RangeError unless (-180..180).member?(lon)

  @lat = lat
  @lon = lon
  @time = time
end