In Info object is valid if
- it has an event
- it has an urgency with a valid value
- it has a severity with a valid value
- it has a certainty with a valid value
- all categories are valid and categories has at minimum 1 entry
- all Resource objects in the resources collection are valid
- all Area objects in the areas collection are valid
Included modules
- Validation
Constants
| VALID_CATEGORIES | = | [ CATEGORY_GEO, CATEGORY_MET, CATEGORY_SAFETY, CATEGORY_SECURITY, CATEGORY_RESCUE, CATEGORY_FIRE, CATEGORY_HEALTH, CATEGORY_ENV, CATEGORY_TRANSPORT, CATEGORY_INFRA, CATEGORY_CBRNE, CATEGORY_OTHER ] | Valid values for categories | |
| VALID_RESPONSE_TYPES | = | [ RESPONSE_TYPE_SHELTER, RESPONSE_TYPE_EVACUATE, RESPONSE_TYPE_PREPARE, RESPONSE_TYPE_EXECUTE, RESPONSE_TYPE_MONITOR, RESPONSE_TYPE_ASSESS, RESPONSE_TYPE_AVOID, RESPONSE_TYPE_ALL_CLEAR, RESPONSE_TYPE_NONE ] | Valid values for response_type | |
| VALID_URGENCIES | = | [ URGENCY_IMMEDIATE, URGENCY_EXPECTED, URGENCY_FUTURE, URGENCY_PAST, URGENCY_UNKNOWN ] | Valid values for urgency | |
| VALID_SEVERITIES | = | [ SEVERITY_EXTREME, SEVERITY_SEVERE, SEVERITY_MODERATE, SEVERITY_MINOR, SEVERITY_UNKNOWN ] | Valid values for severity | |
| VALID_CERTAINTIES | = | [ CERTAINTY_OBSERVED, CERTAINTY_LIKELY, CERTAINTY_POSSIBLE, CERTAINTY_UNLIKELY, CERTAINTY_UNKNOWN ] | Valid valies for certainty | |
| DEFAULT_LANGUAGE | = | 'en-US' |
Attributes
| areas | [R] | Collection of Area objects |
| audience | [RW] | |
| categories | [R] | Collection of textual categories; elements can be one of VALID_CATEGORIES |
| certainty | [RW] | Value can only be one of VALID_CERTAINTIES |
| contact | [RW] | |
| description | [RW] | |
| effective | [RW] | Effective start time of information |
| event | [RW] | |
| event_codes | [R] | Collectoin of EventCode objects |
| expires | [RW] | Effective expiry time of information |
| headline | [RW] | |
| instruction | [RW] | |
| language | [RW] | |
| onset | [RW] | Expected start of event |
| parameters | [R] | Collection of Parameter objects |
| resources | [R] | Collection of Resource objects |
| response_types | [R] | Collection of textual response types |
| sender_name | [RW] | |
| severity | [RW] | Value can only be one of VALID_SEVERITIES |
| urgency | [RW] | Value can only be one of VALID_URGENCIES |
| web | [RW] |
Public class methods
# File lib/rcap/cap_1_2/info.rb, line 159 def initialize( attributes = {} ) @language = attributes[ :language ] || DEFAULT_LANGUAGE @categories = Array( attributes[ :categories ]) @event = attributes [ :event ] @response_types = Array( attributes[ :response_types ]) @urgency = attributes[ :urgency ] @severity = attributes[ :severity ] @certainty = attributes[ :certainty ] @effective = attributes[ :effective ] @onset = attributes[ :onset ] @expires = attributes[ :expires ] @event_codes = Array( attributes[ :event_codes ]) @sender_name = attributes[ :sender_name ] @headline = attributes[ :headline ] @description = attributes[ :description ] @instruction = attributes[ :instruction ] @web = attributes[ :web ] @contact = attributes[ :contact ] @parameters = Array( attributes[ :parameters ]) @resources = Array( attributes[ :resources ]) @areas = Array( attributes[ :areas ]) end
Public instance methods
Creates a new Area object and adds it to the areas array. The area_attributes are passed as a parameter to Area.new.
# File lib/rcap/cap_1_2/info.rb, line 208 def add_area( area_attributes = {}) area = Area.new( area_attributes ) self.areas << area area end
Creates a new EventCode object and adds it to the event_codes array. The event_code_attributes are passed as a parameter to EventCode.new.
# File lib/rcap/cap_1_2/info.rb, line 184 def add_event_code( event_code_attributes = {}) event_code = EventCode.new( event_code_attributes ) self.event_codes << event_code event_code end
Creates a new Parameter object and adds it to the parameters array. The parameter_attributes are passed as a parameter to Parameter.new.
# File lib/rcap/cap_1_2/info.rb, line 192 def add_parameter( parameter_attributes = {}) parameter = Parameter.new( parameter_attributes ) self.parameters << parameter parameter end
Creates a new Resource object and adds it to the resources array. The resource_attributes are passed as a parameter to Resource.new.
# File lib/rcap/cap_1_2/info.rb, line 200 def add_resource( resource_attributes = {}) resource = Resource.new( resource_attributes ) self.resources << resource resource end
Returns a string representation of the event of the form
event(urgency/severity/certainty)
# File lib/rcap/cap_1_2/info.rb, line 287 def to_s "#{ self.event }(#{ self.urgency }/#{ self.severity }/#{ self.certainty })" end