Class: Puree::XMLExtractor::Event

Inherits:
Resource show all
Defined in:
lib/puree/xml_extractor/event.rb

Overview

Event XML extractor.

Instance Method Summary collapse

Methods inherited from Resource

#created, #get_data?, #locale, #modified, #uuid, #xpath_query

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.



9
10
11
12
# File 'lib/puree/xml_extractor/event.rb', line 9

def initialize(xml:)
  super
  @resource_type = :event
end

Instance Method Details

#cityString?

Returns:

  • (String, nil)


15
16
17
# File 'lib/puree/xml_extractor/event.rb', line 15

def city
  xpath_query_for_single_value '/city'
end

#countryString?

Returns:

  • (String, nil)


20
21
22
# File 'lib/puree/xml_extractor/event.rb', line 20

def country
  xpath_query_for_single_value '/country/term/localizedString'
end

#datePuree::Model::TemporalRange?

Returns:



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/puree/xml_extractor/event.rb', line 25

def date
  xpath_result = xpath_query '/dateRange'
  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)


40
41
42
# File 'lib/puree/xml_extractor/event.rb', line 40

def description
  xpath_query_for_single_value '/description'
end

#locationString?

Returns:

  • (String, nil)


45
46
47
# File 'lib/puree/xml_extractor/event.rb', line 45

def location
  xpath_query_for_single_value '/location'
end

#titleString?

Returns:

  • (String, nil)


50
51
52
# File 'lib/puree/xml_extractor/event.rb', line 50

def title
  xpath_query_for_single_value '/title/localizedString'
end

#typeString?

Returns:

  • (String, nil)


55
56
57
# File 'lib/puree/xml_extractor/event.rb', line 55

def type
  xpath_query_for_single_value '//typeClassification/term/localizedString'
end