Class: MeteofranceApi::Rain
- Inherits:
-
Object
- Object
- MeteofranceApi::Rain
- Defined in:
- lib/meteofrance_api/models/rain.rb
Defined Under Namespace
Classes: Forecast
Instance Attribute Summary collapse
-
#altitude ⇒ Object
readonly
Returns the value of attribute altitude.
-
#confidence ⇒ Object
readonly
quality of the rain forecast.
-
#forecasts ⇒ Object
readonly
the rain forecast.
-
#french_department ⇒ Object
readonly
Returns the value of attribute french_department.
-
#place_name ⇒ Object
readonly
position information of the rain forecast ([latitude, longitude]).
-
#position ⇒ Object
readonly
Returns the value of attribute position.
-
#timezone ⇒ Object
readonly
Returns the value of attribute timezone.
-
#updated_on ⇒ Object
readonly
update time of the rain forecast.
Instance Method Summary collapse
-
#initialize(data) ⇒ Rain
constructor
A new instance of Rain.
-
#next_rain_date(use_position_timezone) ⇒ Object
Estimate the date of the next rain.
- #to_locale_timezone(time) ⇒ Object
Constructor Details
#initialize(data) ⇒ Rain
Returns a new instance of Rain.
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/meteofrance_api/models/rain.rb', line 15 def initialize(data) @updated_on = Time.at(data["updated_time"]).utc @position = data["geometry"]["coordinates"] @place_name = data["properties"]["name"] @altitude = data["properties"]["altitude"] @french_department = data["properties"]["french_department"] @timezone = data["properties"]["timezone"] @forecasts = data["properties"]["forecast"].map {|d| MeteofranceApi::Rain::Forecast.new(d)} @confidence = data["properties"]["confidence"] end |
Instance Attribute Details
#altitude ⇒ Object (readonly)
Returns the value of attribute altitude.
7 8 9 |
# File 'lib/meteofrance_api/models/rain.rb', line 7 def altitude @altitude end |
#confidence ⇒ Object (readonly)
quality of the rain forecast.
13 14 15 |
# File 'lib/meteofrance_api/models/rain.rb', line 13 def confidence @confidence end |
#forecasts ⇒ Object (readonly)
the rain forecast.
11 12 13 |
# File 'lib/meteofrance_api/models/rain.rb', line 11 def forecasts @forecasts end |
#french_department ⇒ Object (readonly)
Returns the value of attribute french_department.
8 9 10 |
# File 'lib/meteofrance_api/models/rain.rb', line 8 def french_department @french_department end |
#place_name ⇒ Object (readonly)
position information of the rain forecast ([latitude, longitude]).
5 6 7 |
# File 'lib/meteofrance_api/models/rain.rb', line 5 def place_name @place_name end |
#position ⇒ Object (readonly)
Returns the value of attribute position.
6 7 8 |
# File 'lib/meteofrance_api/models/rain.rb', line 6 def position @position end |
#timezone ⇒ Object (readonly)
Returns the value of attribute timezone.
9 10 11 |
# File 'lib/meteofrance_api/models/rain.rb', line 9 def timezone @timezone end |
#updated_on ⇒ Object (readonly)
update time of the rain forecast.
3 4 5 |
# File 'lib/meteofrance_api/models/rain.rb', line 3 def updated_on @updated_on end |
Instance Method Details
#next_rain_date(use_position_timezone) ⇒ Object
Estimate the date of the next rain.
Returns:
A datetime instance representing the date estimation of the next rain within
the next hour.
If no rain is expected in the following hour nil is returned.
36 37 38 39 40 41 |
# File 'lib/meteofrance_api/models/rain.rb', line 36 def next_rain_date(use_position_timezone) # search first cadran with rain next_rain = forecasts.find {|f| f.intensity > 1} next_rain&.time end |
#to_locale_timezone(time) ⇒ Object
26 27 28 |
# File 'lib/meteofrance_api/models/rain.rb', line 26 def to_locale_timezone(time) time.in_time_zone(position["timezone"]) end |