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
-
#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
-
#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.
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 |
# File 'lib/zvent/event.rb', line 11 def initialize(event_hash) begin event_hash.each_pair{|key, value| self.send("#{key}=", value) } rescue NoMethodError => e # Do nothing! end end |
Instance Attribute Details
#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
40 41 42 |
# File 'lib/zvent/event.rb', line 40 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
24 25 26 |
# File 'lib/zvent/event.rb', line 24 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
73 |
# File 'lib/zvent/event.rb', line 73 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)
95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/zvent/event.rb', line 95 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
58 59 60 |
# File 'lib/zvent/event.rb', line 58 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)
82 83 84 |
# File 'lib/zvent/event.rb', line 82 def image(size='original') self.images? ? convert_image(@images.first, size) : nil end |
#images? ⇒ Boolean
Does the event have any images
55 |
# File 'lib/zvent/event.rb', line 55 def images? ; !(@images.nil? || @images.empty?); end |
#tz_timezone ⇒ Object
Returns the tz timezone object from the venue
52 |
# File 'lib/zvent/event.rb', line 52 def tz_timezone ; @venue.tz_timezone; end |