Class: Puree::Event

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

Overview

Event resource

Instance Attribute Summary

Attributes inherited from Resource

#response

Instance Method Summary collapse

Methods inherited from Resource

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

Constructor Details

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

Returns a new instance of Event.

Parameters:

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

    username [String]

  • optional

    password [String]

  • optional

    basic_auth [Boolean]



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

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

Instance Method Details

#cityString

City

Returns:

  • (String)


25
26
27
28
# File 'lib/puree/event.rb', line 25

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

#countryString

Country

Returns:

  • (String)


33
34
35
36
# File 'lib/puree/event.rb', line 33

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

#dateHash

Date

Returns:

  • (Hash)


41
42
43
44
45
46
47
48
# File 'lib/puree/event.rb', line 41

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)


53
54
55
56
# File 'lib/puree/event.rb', line 53

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

#locationString

Location

Returns:

  • (String)


61
62
63
64
# File 'lib/puree/event.rb', line 61

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

#metadataHash

All metadata

Returns:

  • (Hash)


85
86
87
88
89
90
91
92
93
94
95
# File 'lib/puree/event.rb', line 85

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)


69
70
71
72
# File 'lib/puree/event.rb', line 69

def title
  path = '/title/localizedString'
  xpath_query_for_single_value path
end

#typeString

Type

Returns:

  • (String)


77
78
79
80
# File 'lib/puree/event.rb', line 77

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