Class: SemanticCrawler::Gdacs::EmergencyFeedItem

Inherits:
Object
  • Object
show all
Defined in:
lib/semantic_crawler/gdacs/emergency_feed_item.rb

Overview

One emergency crisis entity.

Constant Summary collapse

@@NAMESPACES =

XML namespaces used for the parsing process

{
    "gdacs" => "http://www.gdacs.org",
    "glide" => "http://glidenumber.net"
}

Instance Method Summary collapse

Constructor Details

#initialize(new_root_node) ⇒ EmergencyFeedItem

Returns a new instance of EmergencyFeedItem.



13
14
15
# File 'lib/semantic_crawler/gdacs/emergency_feed_item.rb', line 13

def initialize(new_root_node)
    @root_node = new_root_node
end

Instance Method Details

#eventTypeObject

Returns a human readable event type



33
34
35
# File 'lib/semantic_crawler/gdacs/emergency_feed_item.rb', line 33

def eventType
    query_root_node("gdacs:eventType/text()", @@NAMESPACES)
end

#glideObject

Returns the glide number



42
43
44
# File 'lib/semantic_crawler/gdacs/emergency_feed_item.rb', line 42

def glide
    query_root_node("glide:number/text()", @@NAMESPACES)
end

#lastUpdateObject

Returns the last updated datetime



38
39
40
# File 'lib/semantic_crawler/gdacs/emergency_feed_item.rb', line 38

def lastUpdate
    query_root_node("gdacs:lastUpdate/text()", @@NAMESPACES)
end

Returns the crisis gdacs link



23
24
25
# File 'lib/semantic_crawler/gdacs/emergency_feed_item.rb', line 23

def link
    query_root_node("link/text()")
end

#pubDateObject

Returns the publication date



28
29
30
# File 'lib/semantic_crawler/gdacs/emergency_feed_item.rb', line 28

def pubDate
    query_root_node("pubDate/text()")
end

#query_root_node(xpath_query, namespaces = {}) ⇒ Object

Query the root_node



47
48
49
50
51
# File 'lib/semantic_crawler/gdacs/emergency_feed_item.rb', line 47

def query_root_node(xpath_query, namespaces = {})
    if !@root_node.nil?
        @root_node.xpath(xpath_query, namespaces)
    end
end

#titleObject

Returns the crisis title



18
19
20
# File 'lib/semantic_crawler/gdacs/emergency_feed_item.rb', line 18

def title
    query_root_node("title/text()")
end