# RCAP - Common Alerting Protocl for Ruby

**URL:** <https://www.ruby-forum.com/t/rcap-common-alerting-protocl-for-ruby/178389>\
**Category:** Ruby\
**Created:** [November 3, 2009, 9:32pm UTC](https://www.ruby-forum.com/t/rcap-common-alerting-protocl-for-ruby/178389 "2009-11-03T21:32:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Farrel\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9d8465/32.png) [@Farrel\_L](https://www.ruby-forum.com/u/Farrel_L)\
**Post date:** [November 3, 2009, 9:32pm UTC](https://www.ruby-forum.com/t/rcap-common-alerting-protocl-for-ruby/178389/1 "2009-11-03T21:32:59Z")

</div>

OVERVIEW

RCAP is an implementation of the CAP in Ruby. It allows for the  
creation of RCAP messages from Ruby applications and the parsing of  
external messages.

RCAP currently supports only CAP Version 1.1.

RCAP is released under the BSD License.

INSTALLATION

RCAP is distributed as a Ruby gem and is available from Gemcutter. If  
you have Gemcutter set as a source of your gems then RCAP can be  
installed from the command line

$ gem install rcap

The gem is also available for download and manual installtion at  
[Aimred - Gem Archive](http://www.aimred.com/gems) .

WEB RESOURCES

```
* The RCAP project page can be found at www.aimred.com/projects/rcap
* The RCAP API docs can be fount at www.aimred.com/projects/rcap/api

```

USAGE

alert = Alert.new( :sender =\>  
‘removed\_email\_address@domain.invalid’,  
:status =\> Alert::STATUS\_ACTUAL,  
:msg\_type =\> Alert::MSG\_TYPE\_ALERT,  
:scope =\> Alert::SCOPE\_PUBLIC,  
:infos =\> Info.new( :event =\> ‘Liquid  
Petroleoum Tanker Fire’,  
:language =\> ‘en-ZA’,  
:categories =\> [  
Info::CATEGORY\_TRANSPORT, Info::CATEGORY\_FIRE ],  
:urgency =\>  
Info::URGENCY\_IMMEDIATE,  
:severity =\>  
Info::SEVERITY\_SEVERE,  
:certainty =\>  
Info::CERTAINTY\_OBSERVED,  
:headline =\> ‘LIQUID  
PETROLEOUM TANKER FIRE ON N2 INCOMING FREEWAY’,  
:description =\> ‘A liquid  
petroleoum tanker has caught fire on the N2 incoming freeway 1km  
after the  
R300 interchange. Municipal fire fighting crews have been dispatched.  
Traffic  
control officers are on the scene and have diverted traffic onto  
alternate  
routes.’ ))

# Accessing attributes

puts alert.status # Print out “Actual”  
puts alert.infos[0].language # Print out “en-ZA”  
puts alert.infos[0].categories.join( ’ ’ ) # Print out “Transport Fire”

puts alert.to\_xml # Print out CAP XML message

will produce the following CAP XML Message

 \<?xml version='1.0'?\> 494207a7-f86b-4060-8318-a4b2a3ce565e removed\_email\_address@domain.invalid 2009-10-26T21:04:51+02:00 Actual Alert Public en-ZA Transport Fire Liquid Petroleoum Tanker Fire Immediate Severe Observed LIQUID PETROLEOUM TANKER FIRE ON N2 INCOMING FREEWAY A liquid petroleoum tanker has caught fire on the N2 incoming freeway 1km after the R300 interchange. Municipal fire fighting crews have been dispatched. Traffic control officers are on the scene and have diverted traffic onto alternate routes. 

Farrel L.

---

<div class="post-metadata">

**Author:** ![Farrel\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9d8465/32.png) [@Farrel\_L](https://www.ruby-forum.com/u/Farrel_L)\
**Post date:** [November 3, 2009, 9:39pm UTC](https://www.ruby-forum.com/t/rcap-common-alerting-protocl-for-ruby/178389/2 "2009-11-03T21:39:25Z")

</div>

Apologies for the bad code formatting. The RCAP project page -  
[Aimred - RCAP - Common Alerting Protocol for Ruby](http://www.aimred.com/projects/rcap) - makes it look a lot better.

Farrel
