Class: Puree::Event

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

Overview

Event resource

Instance Method Summary collapse

Methods inherited from Resource

#content, #created, #get, #modified, #response, #set_content, #uuid

Constructor Details

#initialize(endpoint: nil, username: nil, password: nil) ⇒ Event

Returns a new instance of Event.

Parameters:

  • endpoint (String) (defaults to: nil)
  • optional

    username [String]

  • optional

    password [String]



10
11
12
13
14
15
# File 'lib/puree/event.rb', line 10

def initialize(endpoint: nil, username: nil, password: nil)
  super(api: :event,
        endpoint: endpoint,
        username: username,
        password: password)
end

Instance Method Details

#cityString

City

Returns:

  • (String)


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

def city
  path = '//city'
  xpath_query(path).text.strip
end

#countryString

Country

Returns:

  • (String)


28
29
30
31
# File 'lib/puree/event.rb', line 28

def country
  path = '//country/term/localizedString'
  xpath_query(path).text.strip
end

#dateHash

Date

Returns:

  • (Hash)


36
37
38
39
40
41
42
43
# File 'lib/puree/event.rb', line 36

def date
  data = {}
  path = '//dateRange'
  range = xpath_query path
  data['start'] = range.xpath('startDate').text.strip
  data['end'] = range.xpath('startDate').text.strip
  data
end

#descriptionString

Description

Returns:

  • (String)


48
49
50
51
# File 'lib/puree/event.rb', line 48

def description
  path = '//content/description'
  xpath_query(path).text.strip
end

#locationString

Location

Returns:

  • (String)


56
57
58
59
# File 'lib/puree/event.rb', line 56

def location
  path = '//location'
  xpath_query(path).text.strip
end

#metadataHash

All metadata

Returns:

  • (Hash)


80
81
82
83
84
85
86
87
88
89
90
# File 'lib/puree/event.rb', line 80

def 
  o = super
  o['city'] = city
  o['country'] = country
  o['date'] = date
  o['description'] = description
  o['location'] = location
  o['title'] = title
  o['type'] = type
  o
end

#titleString

Title

Returns:

  • (String)


64
65
66
67
# File 'lib/puree/event.rb', line 64

def title
  path = '//title/localizedString'
  xpath_query(path).text.strip
end

#typeString

Type

Returns:

  • (String)


72
73
74
75
# File 'lib/puree/event.rb', line 72

def type
  path = '//content/typeClassification/term/localizedString'
  xpath_query(path).text.strip
end