Class: Puree::XMLExtractor::Event

Inherits:
Resource show all
Includes:
TitleMixin, TypeMixin
Defined in:
lib/puree/xml_extractor/event.rb

Overview

Event XML extractor.

Instance Method Summary collapse

Methods included from TypeMixin

#type

Methods included from TitleMixin

#title

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

#cityString?

Returns:

  • (String, nil)


17
18
19
# File 'lib/puree/xml_extractor/event.rb', line 17

def city
  xpath_query_for_single_value '/city'
end

#datePuree::Model::TemporalRange?

Returns:



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

#descriptionString?

Returns:

  • (String, nil)


37
38
39
# File 'lib/puree/xml_extractor/event.rb', line 37

def description
  xpath_query_for_single_value '/description'
end