Class: Puree::XMLExtractor::Event
Overview
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
#city ⇒ String?
15
16
17
|
# File 'lib/puree/xml_extractor/event.rb', line 15
def city
xpath_query_for_single_value '/city'
end
|
#country ⇒ String?
20
21
22
|
# File 'lib/puree/xml_extractor/event.rb', line 20
def country
xpath_query_for_single_value '/country/term/localizedString'
end
|
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
|
#description ⇒ String?
40
41
42
|
# File 'lib/puree/xml_extractor/event.rb', line 40
def description
xpath_query_for_single_value '/description'
end
|
#location ⇒ String?
45
46
47
|
# File 'lib/puree/xml_extractor/event.rb', line 45
def location
xpath_query_for_single_value '/location'
end
|
#title ⇒ String?
50
51
52
|
# File 'lib/puree/xml_extractor/event.rb', line 50
def title
xpath_query_for_single_value '/title/localizedString'
end
|
#type ⇒ String?
55
56
57
|
# File 'lib/puree/xml_extractor/event.rb', line 55
def type
xpath_query_for_single_value '//typeClassification/term/localizedString'
end
|