Class: MeteofranceApi::Warning::Full

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

Overview

This class allows to access the results of a ‘warning/full` API command.

For a given domain we can access the maximum alert, a timelaps of the alert evolution for the next 24 hours, and a list of alerts.

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Full

Returns a new instance of Full.



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/meteofrance_api/models/warning/full.rb', line 29

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

  @advices = data["advices"]
  @consequences = data["consequences"]
  @max_count_items = data["max_count_items"]
  @comments = data["comments"]
  @text = data["text"]
  @text["text_avalanche"]
end

Instance Attribute Details

#advicesObject (readonly)

Returns the value of attribute advices.



22
23
24
# File 'lib/meteofrance_api/models/warning/full.rb', line 22

def advices
  @advices
end

#color_maxObject (readonly)

color max of the domain.



16
17
18
# File 'lib/meteofrance_api/models/warning/full.rb', line 16

def color_max
  @color_max
end

#commentsObject (readonly)

Returns the value of attribute comments.



25
26
27
# File 'lib/meteofrance_api/models/warning/full.rb', line 25

def comments
  @comments
end

#consequencesObject (readonly)

Returns the value of attribute consequences.



23
24
25
# File 'lib/meteofrance_api/models/warning/full.rb', line 23

def consequences
  @consequences
end

#domain_idObject (readonly)

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



14
15
16
# File 'lib/meteofrance_api/models/warning/full.rb', line 14

def domain_id
  @domain_id
end

#end_validity_timeObject (readonly)

end of validty time of the full bulletin.



12
13
14
# File 'lib/meteofrance_api/models/warning/full.rb', line 12

def end_validity_time
  @end_validity_time
end

#max_count_itemsObject (readonly)

Returns the value of attribute max_count_items.



24
25
26
# File 'lib/meteofrance_api/models/warning/full.rb', line 24

def max_count_items
  @max_count_items
end

#phenomenonsObject (readonly)

phenomenom list of the domain.



20
21
22
# File 'lib/meteofrance_api/models/warning/full.rb', line 20

def phenomenons
  @phenomenons
end

#textObject (readonly)

Returns the value of attribute text.



26
27
28
# File 'lib/meteofrance_api/models/warning/full.rb', line 26

def text
  @text
end

#text_avalancheObject (readonly)

Returns the value of attribute text_avalanche.



27
28
29
# File 'lib/meteofrance_api/models/warning/full.rb', line 27

def text_avalanche
  @text_avalanche
end

#timelapsObject (readonly)

timelaps of each phenomenom for the domain. A list of Hash corresponding to the schedule of each phenomenons in the next 24 hours



18
19
20
# File 'lib/meteofrance_api/models/warning/full.rb', line 18

def timelaps
  @timelaps
end

#update_timeObject (readonly)

update time of the full bulletin.



10
11
12
# File 'lib/meteofrance_api/models/warning/full.rb', line 10

def update_time
  @update_time
end

Instance Method Details

#merge_with_coastal_phenomenons!(coastal_phenomenons) ⇒ Object

Args:

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


53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/meteofrance_api/models/warning/full.rb', line 53

def merge_with_coastal_phenomenons!(coastal_phenomenons)
  # TODO: Add consitency check
  # TODO: Check if other data need to be merged

  @color_max = [color_max, coastal_phenomenons.color_max].max

  # Merge timelaps
  @timelaps += coastal_phenomenons.timelaps

  # Merge phenomenons
  @phenomenons += coastal_phenomenons.phenomenons
end