Class: Zvent::Event

Inherits:
Base show all
Defined in:
lib/zvent/event.rb

Overview

An object that represents a single event from zvents

Constant Summary collapse

IMAGE_SIZES =
['tiny', 'medium', 'featured', 'primary', 'original']

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#get_resources

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_suitabilityObject

Returns the value of attribute age_suitability.



6
7
8
# File 'lib/zvent/event.rb', line 6

def age_suitability
  @age_suitability
end

#approvedObject

Returns the value of attribute approved.



6
7
8
# File 'lib/zvent/event.rb', line 6

def approved
  @approved
end

#artistsObject

Returns the value of attribute artists.



6
7
8
# File 'lib/zvent/event.rb', line 6

def artists
  @artists
end

#categoriesObject

Returns the value of attribute categories.



6
7
8
# File 'lib/zvent/event.rb', line 6

def categories
  @categories
end

#colorObject

Returns the value of attribute color.



6
7
8
# File 'lib/zvent/event.rb', line 6

def color
  @color
end

#descriptionObject

Returns the value of attribute description.



6
7
8
# File 'lib/zvent/event.rb', line 6

def description
  @description
end

#editors_pickObject

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

#idObject

Returns the value of attribute id.



6
7
8
# File 'lib/zvent/event.rb', line 6

def id
  @id
end

#imagesObject

Returns the value of attribute images.



6
7
8
# File 'lib/zvent/event.rb', line 6

def images
  @images
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/zvent/event.rb', line 6

def name
  @name
end

#phoneObject

Returns the value of attribute phone.



6
7
8
# File 'lib/zvent/event.rb', line 6

def phone
  @phone
end

#priceObject

Returns the value of attribute price.



6
7
8
# File 'lib/zvent/event.rb', line 6

def price
  @price
end

#privateObject

Returns the value of attribute private.



6
7
8
# File 'lib/zvent/event.rb', line 6

def private
  @private
end

#scObject

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

#urlObject

Returns the value of attribute url.



6
7
8
# File 'lib/zvent/event.rb', line 6

def url
  @url
end

#venueObject

Returns the value of attribute venue.



6
7
8
# File 'lib/zvent/event.rb', line 6

def venue
  @venue
end

#vidObject

Returns the value of attribute vid.



6
7
8
# File 'lib/zvent/event.rb', line 6

def vid
  @vid
end

#zurlObject

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?

Returns:

  • (Boolean)


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

Returns:

  • (Boolean)


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

Returns:

  • (Boolean)


61
# File 'lib/zvent/event.rb', line 61

def images?  ; !(@images.nil? || @images.empty?); end

#tz_timezoneObject

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

Returns:

  • (Boolean)


116
# File 'lib/zvent/event.rb', line 116

def venue? ; !(@venue.nil?) ; end