Class: Puree::XMLExtractor::Event
- Includes:
- TitleMixin, TypeMixin
- Defined in:
- lib/puree/xml_extractor/event.rb
Overview
Event XML extractor.
Instance Method Summary collapse
- #city ⇒ String?
- #date ⇒ Puree::Model::TemporalRange?
- #description ⇒ String?
-
#initialize(xml) ⇒ Event
constructor
A new instance of Event.
Methods included from TypeMixin
Methods included from TitleMixin
Methods inherited from Resource
#created_at, #created_by, #id, #model, #modified_at, #modified_by, #previous_uuids, #uuid
Methods inherited from Base
#xpath_query_for_multi_value, #xpath_query_for_single_value
Constructor Details
#initialize(xml) ⇒ Event
Returns a new instance of Event.
11 12 13 14 |
# File 'lib/puree/xml_extractor/event.rb', line 11 def initialize(xml) super setup_model :event end |
Instance Method Details
#city ⇒ String?
17 18 19 |
# File 'lib/puree/xml_extractor/event.rb', line 17 def city xpath_query_for_single_value '/city' end |
#date ⇒ Puree::Model::TemporalRange?
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/puree/xml_extractor/event.rb', line 22 def date xpath_result = xpath_query '/period' range_start_str = xpath_result.xpath('startDate').text.strip range_end_str = xpath_result.xpath('endDate').text.strip if !range_start_str.empty? range = Puree::Model::TemporalRange.new range.start = Time.parse range_start_str if !range_end_str.empty? range.end = Time.parse range_end_str end range end end |
#description ⇒ String?
37 38 39 |
# File 'lib/puree/xml_extractor/event.rb', line 37 def description xpath_query_for_single_value '/description' end |