Class: Zvent::Event
Overview
An object that represents a single event from zvents
Constant Summary collapse
- IMAGE_SIZES =
['tiny', 'medium', 'featured', 'primary', 'original']
Instance Attribute Summary collapse
-
#age_suitability ⇒ Object
Returns the value of attribute age_suitability.
-
#approved ⇒ Object
Returns the value of attribute approved.
-
#artists ⇒ Object
Returns the value of attribute artists.
-
#categories ⇒ Object
Returns the value of attribute categories.
-
#color ⇒ Object
Returns the value of attribute color.
-
#description ⇒ Object
Returns the value of attribute description.
-
#editors_pick ⇒ Object
Returns the value of attribute editors_pick.
-
#endTime(utc = true) ⇒ Object
Get the end time of the event.
-
#id ⇒ Object
Returns the value of attribute id.
-
#images ⇒ Object
Returns the value of attribute images.
-
#name ⇒ Object
Returns the value of attribute name.
-
#phone ⇒ Object
Returns the value of attribute phone.
-
#price ⇒ Object
Returns the value of attribute price.
-
#private ⇒ Object
Returns the value of attribute private.
-
#sc ⇒ Object
Returns the value of attribute sc.
-
#startTime(utc = true) ⇒ Object
Get the start time of the event.
-
#url ⇒ Object
Returns the value of attribute url.
-
#venue ⇒ Object
Returns the value of attribute venue.
-
#vid ⇒ Object
Returns the value of attribute vid.
-
#zurl ⇒ Object
Returns the value of attribute zurl.
Instance Method Summary collapse
-
#category? ⇒ Boolean
Does the event have any categories attached to it?.
-
#deep_image(size = 'original') ⇒ Object
Returns the first image it sees.
-
#deep_images? ⇒ Boolean
Does the event or venue have any images.
-
#image(size = 'original') ⇒ Object
Returns the first image it sees from event.
-
#images? ⇒ Boolean
Does the event have any images.
-
#initialize(event_hash) ⇒ Event
constructor
expects the json hash that is given from zvents.
-
#tz_timezone ⇒ Object
Returns the tz timezone object from the venue.
-
#venue? ⇒ Boolean
Checks to see if the event has a venue.
Methods inherited from Base
Constructor Details
#initialize(event_hash) ⇒ Event
expects the json hash that is given from zvents
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/zvent/event.rb', line 11 def initialize(event_hash) event_hash.each_pair do |key, value| begin self.send("#{key}=", value) rescue NoMethodError => e #do nothing end end # Zvents Partner API self.zurl ||= event_hash['link'] self.startTime ||= event_hash['starttime'] end |
Instance Attribute Details
#age_suitability ⇒ Object
Returns the value of attribute age_suitability.
6 7 8 |
# File 'lib/zvent/event.rb', line 6 def age_suitability @age_suitability end |
#approved ⇒ Object
Returns the value of attribute approved.
6 7 8 |
# File 'lib/zvent/event.rb', line 6 def approved @approved end |
#artists ⇒ Object
Returns the value of attribute artists.
6 7 8 |
# File 'lib/zvent/event.rb', line 6 def artists @artists end |
#categories ⇒ Object
Returns the value of attribute categories.
6 7 8 |
# File 'lib/zvent/event.rb', line 6 def categories @categories end |
#color ⇒ Object
Returns the value of attribute color.
6 7 8 |
# File 'lib/zvent/event.rb', line 6 def color @color end |
#description ⇒ Object
Returns the value of attribute description.
6 7 8 |
# File 'lib/zvent/event.rb', line 6 def description @description end |
#editors_pick ⇒ Object
Returns the value of attribute editors_pick.
6 7 8 |
# File 'lib/zvent/event.rb', line 6 def editors_pick @editors_pick end |
#endTime(utc = true) ⇒ Object
Get the end time of the event. Events are not guaranteed an end time.
The function will return a DateTime object of the time. If there isn’t an endtime it will return nil.
options utc
- Want the time in local (to the venue) or in UTC? Defaults to UTC
46 47 48 |
# File 'lib/zvent/event.rb', line 46 def endTime @endTime end |
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/zvent/event.rb', line 6 def id @id end |
#images ⇒ Object
Returns the value of attribute images.
6 7 8 |
# File 'lib/zvent/event.rb', line 6 def images @images end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/zvent/event.rb', line 6 def name @name end |
#phone ⇒ Object
Returns the value of attribute phone.
6 7 8 |
# File 'lib/zvent/event.rb', line 6 def phone @phone end |
#price ⇒ Object
Returns the value of attribute price.
6 7 8 |
# File 'lib/zvent/event.rb', line 6 def price @price end |
#private ⇒ Object
Returns the value of attribute private.
6 7 8 |
# File 'lib/zvent/event.rb', line 6 def private @private end |
#sc ⇒ Object
Returns the value of attribute sc.
6 7 8 |
# File 'lib/zvent/event.rb', line 6 def sc @sc end |
#startTime(utc = true) ⇒ Object
Get the start time of the event. Events are guaranteed an start time.
The function will return a DateTime object of the time.
options utc
- Want the time in local (to the venue) or in UTC? Defaults to UTC
30 31 32 |
# File 'lib/zvent/event.rb', line 30 def startTime @startTime end |
#url ⇒ Object
Returns the value of attribute url.
6 7 8 |
# File 'lib/zvent/event.rb', line 6 def url @url end |
#venue ⇒ Object
Returns the value of attribute venue.
6 7 8 |
# File 'lib/zvent/event.rb', line 6 def venue @venue end |
#vid ⇒ Object
Returns the value of attribute vid.
6 7 8 |
# File 'lib/zvent/event.rb', line 6 def vid @vid end |
#zurl ⇒ Object
Returns the value of attribute zurl.
6 7 8 |
# File 'lib/zvent/event.rb', line 6 def zurl @zurl end |
Instance Method Details
#category? ⇒ Boolean
Does the event have any categories attached to it?
80 |
# File 'lib/zvent/event.rb', line 80 def category? ; !(@categories.nil? || @categories.empty?) ; end |
#deep_image(size = 'original') ⇒ Object
Returns the first image it sees. First it checks the event for images thent the venue for images. If none is found it will return nil
size
-
tiny
- 44x44 -
medium
- 66x66 -
featured
- 150x150 -
primary
- 184x184 -
original
Will just grab the original image from zvents (default)
102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/zvent/event.rb', line 102 def deep_image(size='original') image = nil if self.images? image = @images.first elsif self.venue image = @venue.images? ? @venue.images.first : nil else image = nil end (image.nil?) ? image : convert_image(image, size) end |
#deep_images? ⇒ Boolean
Does the event or venue have any images
64 65 66 |
# File 'lib/zvent/event.rb', line 64 def deep_images? self.images? || (@venue.nil? ? false : @venue.images?) end |
#image(size = 'original') ⇒ Object
Returns the first image it sees from event. If none is found it will return nil size
-
tiny
- 44x44 -
medium
- 66x66 -
featured
- 150x150 -
primary
- 184x184 -
original
Will just grab the original image from zvents (default)
89 90 91 |
# File 'lib/zvent/event.rb', line 89 def image(size='original') self.images? ? convert_image(@images.first, size) : nil end |
#images? ⇒ Boolean
Does the event have any images
61 |
# File 'lib/zvent/event.rb', line 61 def images? ; !(@images.nil? || @images.empty?); end |
#tz_timezone ⇒ Object
Returns the tz timezone object from the venue
58 |
# File 'lib/zvent/event.rb', line 58 def tz_timezone ; @venue.tz_timezone; end |
#venue? ⇒ Boolean
Checks to see if the event has a venue
116 |
# File 'lib/zvent/event.rb', line 116 def venue? ; !(@venue.nil?) ; end |