Class: MeteofranceApi::Warning::Current

Inherits:
Object
  • Object
show all
Defined in:
lib/meteofrance_api/models/warning/current.rb

Overview

Class to access the results of a ‘warning/currentPhenomenons` REST API request.

For coastal department two bulletins are avalaible corresponding to two different domains.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Current

Returns a new instance of Current.



15
16
17
18
19
20
# File 'lib/meteofrance_api/models/warning/current.rb', line 15

def initialize(data)
  @update_time = Time.at(data["update_time"])
  @end_validity_time = Time.at(data["end_validity_time"])
  @domain_id = data["domain_id"]
  @phenomenons = (data["phenomenons_max_colors"] || []).map {|i| Warning::Phenomenon.new(i)}
end

Instance Attribute Details

#domain_idObject (readonly)

domain ID of the phenomenons. Value is ‘France’ or a department number



11
12
13
# File 'lib/meteofrance_api/models/warning/current.rb', line 11

def domain_id
  @domain_id
end

#end_validity_timeObject (readonly)

end of validty time of the phenomenoms.



9
10
11
# File 'lib/meteofrance_api/models/warning/current.rb', line 9

def end_validity_time
  @end_validity_time
end

#phenomenonsObject (readonly)

List of Phenomenon



13
14
15
# File 'lib/meteofrance_api/models/warning/current.rb', line 13

def phenomenons
  @phenomenons
end

#update_timeObject (readonly)

update time of the phenomenoms.



7
8
9
# File 'lib/meteofrance_api/models/warning/current.rb', line 7

def update_time
  @update_time
end

Instance Method Details

#get_domain_max_colorObject

Get the maximum level of alert of a given domain (class helper). Returns:

An integer corresponding to the status code representing the maximum alert.


39
40
41
# File 'lib/meteofrance_api/models/warning/current.rb', line 39

def get_domain_max_color
  phenomenons.map {|item| item.max_color_id}.max
end

#merge_with_coastal_phenomenons!(coastal_phenomenons) ⇒ Object

Args:

coastal_phenomenoms: WarningCurrentPhenomenons instance corresponding to the
    coastal weather alert bulletin.


31
32
33
34
# File 'lib/meteofrance_api/models/warning/current.rb', line 31

def merge_with_coastal_phenomenons!(coastal_phenomenons)
  # TODO: Add consitency check
  @phenomenons += coastal_phenomenoms.phenomenons
end