Class: SemanticCrawler::Gdacs::EmergencyFeed
- Inherits:
-
Object
- Object
- SemanticCrawler::Gdacs::EmergencyFeed
- Defined in:
- lib/semantic_crawler/gdacs/emergency_feed.rb
Overview
The emergency GDACS.org RSS feed contains the very, very basic information about emergencies.
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
The gdacs.org RSS feed URL.
Instance Method Summary collapse
-
#description ⇒ Object
Get rss/channel/description.
-
#initialize(new_url = "http://new.gdacs.org/xml/vo.xml") ⇒ EmergencyFeed
constructor
Initializes the gdacs.org feed URL.
-
#items ⇒ Object
Get rss/channel/item*.
-
#query_root_node(xpath_query, namespaces = {}) ⇒ Object
Query the root_node.
-
#title ⇒ Object
Get rss/channel/title.
-
#xml_document ⇒ Object
Returns the whole RSS feed as XML.
Constructor Details
#initialize(new_url = "http://new.gdacs.org/xml/vo.xml") ⇒ EmergencyFeed
Initializes the gdacs.org feed URL. If not specified the default URL (new.gdacs.org/xml/rss.xml) is used. Normally the feed URL should not be changed.
16 17 18 19 20 21 22 23 24 |
# File 'lib/semantic_crawler/gdacs/emergency_feed.rb', line 16 def initialize(new_url = "http://new.gdacs.org/xml/vo.xml") @url = new_url @root_node = nil begin fetch_feed rescue => e $log.error("Not able to get country information, through exception: #{e}") end end |
Instance Attribute Details
#url ⇒ Object (readonly)
The gdacs.org RSS feed URL. (default: new.gdacs.org/xml/rss.xml)
11 12 13 |
# File 'lib/semantic_crawler/gdacs/emergency_feed.rb', line 11 def url @url end |
Instance Method Details
#description ⇒ Object
Get rss/channel/description
32 33 34 |
# File 'lib/semantic_crawler/gdacs/emergency_feed.rb', line 32 def description query_root_node("description/text()") end |
#items ⇒ Object
Get rss/channel/item*
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/semantic_crawler/gdacs/emergency_feed.rb', line 37 def items nodeset = query_root_node("item") @items = [] if !nodeset.nil? nodeset.each do |item| item_obj = SemanticCrawler::Gdacs::EmergencyFeedItem.new(item) @items << item_obj end end @items end |
#query_root_node(xpath_query, namespaces = {}) ⇒ Object
Query the root_node
50 51 52 53 54 |
# File 'lib/semantic_crawler/gdacs/emergency_feed.rb', line 50 def query_root_node(xpath_query, namespaces = {}) if !@root_node.nil? @root_node.xpath(xpath_query, namespaces) end end |
#title ⇒ Object
Get rss/channel/title
27 28 29 |
# File 'lib/semantic_crawler/gdacs/emergency_feed.rb', line 27 def title query_root_node("title/text()") end |
#xml_document ⇒ Object
Returns the whole RSS feed as XML
57 58 59 |
# File 'lib/semantic_crawler/gdacs/emergency_feed.rb', line 57 def xml_document @root_node.to_s end |