Class: SemanticCrawler::Gdacs::Resource
- Inherits:
-
Object
- Object
- SemanticCrawler::Gdacs::Resource
- Defined in:
- lib/semantic_crawler/gdacs/resource.rb
Overview
A resource is always related to one FeedItem and could have different types. For example xml, map and a lot more.
Constant Summary collapse
- @@NAMESPACES =
XML namespaces used for the parsing process
{ "gdacs" => "http://www.gdacs.org" }
Instance Method Summary collapse
-
#accesslevel ⇒ Object
- OPTIONAL
-
Returns the gdacs:accesslevel.
-
#acknowledgements ⇒ Object
- OPTIONAL
-
Returns the gdacs:acknowledgements.
-
#description ⇒ Object
- OPTIONAL
-
Returns the gdacs:description.
-
#initialize(new_root_node) ⇒ Resource
constructor
Initializes a resource that is related to a crisis element.
-
#query_root_node(xpath_query, namespaces = {}) ⇒ Object
Query the root_node.
-
#source ⇒ Object
Returns the source organization abbreviation (‘source’ attribute in gdacs:resource).
-
#title ⇒ Object
Returns the gdacs:title.
-
#type ⇒ Object
Returns the type (attribute in gdacs:resource).
-
#url ⇒ Object
Returns the resource URL.
-
#xslt ⇒ Object
- OPTIONAL
-
Returns the gdacs:xslt.
Constructor Details
#initialize(new_root_node) ⇒ Resource
Initializes a resource that is related to a crisis element.
14 15 16 |
# File 'lib/semantic_crawler/gdacs/resource.rb', line 14 def initialize(new_root_node) @root_node = new_root_node end |
Instance Method Details
#accesslevel ⇒ Object
- OPTIONAL
-
Returns the gdacs:accesslevel
49 50 51 |
# File 'lib/semantic_crawler/gdacs/resource.rb', line 49 def accesslevel query_root_node("gdacs:accesslevel/text()", @@NAMESPACES) end |
#acknowledgements ⇒ Object
- OPTIONAL
-
Returns the gdacs:acknowledgements
44 45 46 |
# File 'lib/semantic_crawler/gdacs/resource.rb', line 44 def acknowledgements query_root_node("gdacs:acknowledgements/text()", @@NAMESPACES) end |
#description ⇒ Object
- OPTIONAL
-
Returns the gdacs:description
39 40 41 |
# File 'lib/semantic_crawler/gdacs/resource.rb', line 39 def description query_root_node("gdacs:description/text()", @@NAMESPACES) end |
#query_root_node(xpath_query, namespaces = {}) ⇒ Object
Query the root_node
59 60 61 62 63 |
# File 'lib/semantic_crawler/gdacs/resource.rb', line 59 def query_root_node(xpath_query, namespaces = {}) if !@root_node.nil? @root_node.xpath(xpath_query, namespaces) end end |
#source ⇒ Object
Returns the source organization abbreviation (‘source’ attribute in gdacs:resource)
34 35 36 |
# File 'lib/semantic_crawler/gdacs/resource.rb', line 34 def source query_root_node("@source") end |
#title ⇒ Object
Returns the gdacs:title
24 25 26 |
# File 'lib/semantic_crawler/gdacs/resource.rb', line 24 def title query_root_node("gdacs:title/text()", @@NAMESPACES) end |
#type ⇒ Object
Returns the type (attribute in gdacs:resource)
29 30 31 |
# File 'lib/semantic_crawler/gdacs/resource.rb', line 29 def type query_root_node("@type") end |
#url ⇒ Object
Returns the resource URL
19 20 21 |
# File 'lib/semantic_crawler/gdacs/resource.rb', line 19 def url query_root_node("@url", @@NAMESPACES).to_s.gsub("[gdacs]", "http://www.gdacs.org") end |
#xslt ⇒ Object
- OPTIONAL
-
Returns the gdacs:xslt. Only for XML resources!
54 55 56 |
# File 'lib/semantic_crawler/gdacs/resource.rb', line 54 def xslt query_root_node("gdacs:xslt/text()", @@NAMESPACES) end |