Class: SemanticCrawler::Gdacs::FeedItem
- Inherits:
-
Object
- Object
- SemanticCrawler::Gdacs::FeedItem
- Defined in:
- lib/semantic_crawler/gdacs/feed_item.rb
Overview
One crisis entity with related resources. Could be one of the following crisis types:
-
Floods
-
Earthquakes
-
Tropical Cyclones
-
Volcanoes
Constant Summary collapse
- @@NAMESPACES =
XML namespaces used for the parsing process
{ "gdacs" => "http://www.gdacs.org", "asgard" => "http://asgard.jrc.it", "geo" => "http://www.w3.org/2003/01/geo/wgs84_pos#", "dc" => "http://purl.org/dc/elements/1.1/" }
Instance Method Summary collapse
-
#alertlevel ⇒ Object
Returns the alert level, could be GREEN, ORANGE or RED.
-
#country ⇒ Object
Returns the country name(s).
-
#description ⇒ Object
Returns the crisis description.
-
#enclosure_length ⇒ Object
Returns the enclosure length, e.g.
-
#enclosure_type ⇒ Object
Returns the enclosure type, e.g.
-
#enclosure_url ⇒ Object
Returns the enclosure URL.
-
#episodeid ⇒ Object
Returns the episode id.
-
#eventid ⇒ Object
Returns the event id.
-
#eventname ⇒ Object
Returns the event name if available.
-
#eventtype ⇒ Object
Returns the event type abbreviation, e.g.
-
#fromdate ⇒ Object
Returns the crisis start date.
-
#glide ⇒ Object
Returns …
-
#guid ⇒ Object
Returns an unique crisis identifier (could be non permanent).
-
#initialize(new_root_node) ⇒ FeedItem
constructor
A new instance of FeedItem.
-
#iso3 ⇒ Object
Returns the country iso3 code if available.
-
#latitude ⇒ Object
Returns the latitude GPS coordinate where the crisis has occurred.
-
#link ⇒ Object
Returns the crisis gdacs link.
-
#longitude ⇒ Object
Returns the longitude GPS coordinate where the crisis has occurred.
-
#population ⇒ Object
Returns the population as human readable string.
-
#population_unit ⇒ Object
Returns the population unit (without further text).
-
#population_value ⇒ Object
Returns the population value (without further text).
-
#pubDate ⇒ Object
Returns the publication date.
-
#query_root_node(xpath_query, namespaces = {}) ⇒ Object
Query the root_node.
-
#resources ⇒ Object
Returns an array of SemanticCrawler::Gdacs::Resource objects.
-
#severity ⇒ Object
Returns the severity as human readable string.
-
#severity_unit ⇒ Object
Returns the severity unit (without further text).
-
#severity_value ⇒ Object
Returns the severity value (without further text).
-
#subject ⇒ Object
Returns the crisis subject abbreviation.
-
#title ⇒ Object
Returns the crisis title.
-
#todate ⇒ Object
Returns the crisis end date.
-
#version ⇒ Object
Returns the version.
-
#vulnerability ⇒ Object
Returns the vulnerability as human readable string.
-
#vulnerability_value ⇒ Object
Returns the vulnerability as number.
Constructor Details
#initialize(new_root_node) ⇒ FeedItem
Returns a new instance of FeedItem.
21 22 23 |
# File 'lib/semantic_crawler/gdacs/feed_item.rb', line 21 def initialize(new_root_node) @root_node = new_root_node end |
Instance Method Details
#alertlevel ⇒ Object
Returns the alert level, could be GREEN, ORANGE or RED
103 104 105 |
# File 'lib/semantic_crawler/gdacs/feed_item.rb', line 103 def alertlevel query_root_node("gdacs:alertlevel/text()", @@NAMESPACES) end |
#country ⇒ Object
Returns the country name(s)
168 169 170 |
# File 'lib/semantic_crawler/gdacs/feed_item.rb', line 168 def country query_root_node("gdacs:country/text()", @@NAMESPACES) end |
#description ⇒ Object
Returns the crisis description
31 32 33 |
# File 'lib/semantic_crawler/gdacs/feed_item.rb', line 31 def description query_root_node("description/text()") end |
#enclosure_length ⇒ Object
Returns the enclosure length, e.g. 1
46 47 48 |
# File 'lib/semantic_crawler/gdacs/feed_item.rb', line 46 def enclosure_length query_root_node("enclosure/@length") end |
#enclosure_type ⇒ Object
Returns the enclosure type, e.g. image/png
41 42 43 |
# File 'lib/semantic_crawler/gdacs/feed_item.rb', line 41 def enclosure_type query_root_node("enclosure/@type") end |
#enclosure_url ⇒ Object
Returns the enclosure URL
36 37 38 |
# File 'lib/semantic_crawler/gdacs/feed_item.rb', line 36 def enclosure_url query_root_node("enclosure/@url") end |
#episodeid ⇒ Object
Returns the episode id
118 119 120 |
# File 'lib/semantic_crawler/gdacs/feed_item.rb', line 118 def episodeid query_root_node("gdacs:episodeid/text()", @@NAMESPACES) end |
#eventid ⇒ Object
Returns the event id
113 114 115 |
# File 'lib/semantic_crawler/gdacs/feed_item.rb', line 113 def eventid query_root_node("gdacs:eventid/text()", @@NAMESPACES) end |
#eventname ⇒ Object
Returns the event name if available
108 109 110 |
# File 'lib/semantic_crawler/gdacs/feed_item.rb', line 108 def eventname query_root_node("gdacs:eventname/text()", @@NAMESPACES) end |
#eventtype ⇒ Object
Returns the event type abbreviation, e.g. VO (for volcanic eruption, EQ (for earthquake), FL (for flood), TC (for tropical cyclone)
98 99 100 |
# File 'lib/semantic_crawler/gdacs/feed_item.rb', line 98 def eventtype query_root_node("gdacs:eventtype/text()", @@NAMESPACES) end |
#fromdate ⇒ Object
Returns the crisis start date
61 62 63 |
# File 'lib/semantic_crawler/gdacs/feed_item.rb', line 61 def fromdate query_root_node("gdacs:fromdate/text()", @@NAMESPACES) end |
#glide ⇒ Object
Returns …
173 174 175 |
# File 'lib/semantic_crawler/gdacs/feed_item.rb', line 173 def glide query_root_node("gdacs:glide/text()", @@NAMESPACES) end |
#guid ⇒ Object
Returns an unique crisis identifier (could be non permanent)
76 77 78 |
# File 'lib/semantic_crawler/gdacs/feed_item.rb', line 76 def guid query_root_node("guid/text()") end |
#iso3 ⇒ Object
Returns the country iso3 code if available
163 164 165 |
# File 'lib/semantic_crawler/gdacs/feed_item.rb', line 163 def iso3 query_root_node("gdacs:iso3/text()", @@NAMESPACES) end |
#latitude ⇒ Object
Returns the latitude GPS coordinate where the crisis has occurred
81 82 83 |
# File 'lib/semantic_crawler/gdacs/feed_item.rb', line 81 def latitude query_root_node("geo:Point/geo:lat/text()", @@NAMESPACES) end |
#link ⇒ Object
Returns the crisis gdacs link
51 52 53 |
# File 'lib/semantic_crawler/gdacs/feed_item.rb', line 51 def link query_root_node("link/text()") end |
#longitude ⇒ Object
Returns the longitude GPS coordinate where the crisis has occurred
86 87 88 |
# File 'lib/semantic_crawler/gdacs/feed_item.rb', line 86 def longitude query_root_node("geo:Point/geo:long/text()", @@NAMESPACES) end |
#population ⇒ Object
Returns the population as human readable string
138 139 140 |
# File 'lib/semantic_crawler/gdacs/feed_item.rb', line 138 def population query_root_node("gdacs:population/text()", @@NAMESPACES) end |
#population_unit ⇒ Object
Returns the population unit (without further text)
148 149 150 |
# File 'lib/semantic_crawler/gdacs/feed_item.rb', line 148 def population_unit query_root_node("gdacs:population/@unit", @@NAMESPACES) end |
#population_value ⇒ Object
Returns the population value (without further text)
143 144 145 |
# File 'lib/semantic_crawler/gdacs/feed_item.rb', line 143 def population_value query_root_node("gdacs:population/@value", @@NAMESPACES) end |
#pubDate ⇒ Object
Returns the publication date
56 57 58 |
# File 'lib/semantic_crawler/gdacs/feed_item.rb', line 56 def pubDate query_root_node("pubDate/text()") end |
#query_root_node(xpath_query, namespaces = {}) ⇒ Object
Query the root_node
191 192 193 194 195 |
# File 'lib/semantic_crawler/gdacs/feed_item.rb', line 191 def query_root_node(xpath_query, namespaces = {}) if !@root_node.nil? @root_node.xpath(xpath_query, namespaces) end end |
#resources ⇒ Object
Returns an array of SemanticCrawler::Gdacs::Resource objects
178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/semantic_crawler/gdacs/feed_item.rb', line 178 def resources nodeset = query_root_node("gdacs:resources/gdacs:resource", @@NAMESPACES) @items = [] if !nodeset.nil? nodeset.each do |item| item_obj = SemanticCrawler::Gdacs::Resource.new(item) @items << item_obj end end @items end |
#severity ⇒ Object
Returns the severity as human readable string
123 124 125 |
# File 'lib/semantic_crawler/gdacs/feed_item.rb', line 123 def severity query_root_node("gdacs:severity/text()", @@NAMESPACES) end |
#severity_unit ⇒ Object
Returns the severity unit (without further text)
133 134 135 |
# File 'lib/semantic_crawler/gdacs/feed_item.rb', line 133 def severity_unit query_root_node("gdacs:severity/@unit", @@NAMESPACES) end |
#severity_value ⇒ Object
Returns the severity value (without further text)
128 129 130 |
# File 'lib/semantic_crawler/gdacs/feed_item.rb', line 128 def severity_value query_root_node("gdacs:severity/@value", @@NAMESPACES) end |
#subject ⇒ Object
Returns the crisis subject abbreviation
71 72 73 |
# File 'lib/semantic_crawler/gdacs/feed_item.rb', line 71 def subject query_root_node("dc:subject/text()", @@NAMESPACES) end |
#title ⇒ Object
Returns the crisis title
26 27 28 |
# File 'lib/semantic_crawler/gdacs/feed_item.rb', line 26 def title query_root_node("title/text()") end |
#todate ⇒ Object
Returns the crisis end date
66 67 68 |
# File 'lib/semantic_crawler/gdacs/feed_item.rb', line 66 def todate query_root_node("gdacs:todate/text()", @@NAMESPACES) end |
#version ⇒ Object
Returns the version
91 92 93 |
# File 'lib/semantic_crawler/gdacs/feed_item.rb', line 91 def version query_root_node("gdacs:version/text()", @@NAMESPACES) end |
#vulnerability ⇒ Object
Returns the vulnerability as human readable string
153 154 155 |
# File 'lib/semantic_crawler/gdacs/feed_item.rb', line 153 def vulnerability query_root_node("gdacs:vulnerability/text()", @@NAMESPACES) end |
#vulnerability_value ⇒ Object
Returns the vulnerability as number
158 159 160 |
# File 'lib/semantic_crawler/gdacs/feed_item.rb', line 158 def vulnerability_value query_root_node("gdacs:vulnerability/@value", @@NAMESPACES) end |