class GigatoolsEvent

Attributes

artists[R]
city[R]
country[R]
eventdate[R]
id[R]
image_url[R]
info[R]
name[R]
showtime[R]
state[R]
url[R]
url_tix[R]
venue[R]

Public Class Methods

create_list(events_json) click to toggle source

Returns an array of GigatoolsEvent objects created from a JSON list

# File lib/gigatools/gigatools_event.rb, line 19
def self.create_list(events_json)
  events = []
  events_json.each do |event|
    events << GigatoolsEvent.new(event["event"])
  end

  return events
end
new(event_json) click to toggle source
# File lib/gigatools/gigatools_event.rb, line 12
def initialize(event_json)
  self.set_attributes(event_json)
  @eventdate = Date.parse(event_json["eventdate"]) if event_json["eventdate"]
  @showtime = Time.parse(event_json["showtime"]) if event_json["showtime"]
end

Public Instance Methods

event_date(format = "%^a %d %^b") click to toggle source

Returns a stringified version of the event date. Takes an optional strftime string as an argument for formatting.

# File lib/gigatools/gigatools_event.rb, line 36
def event_date(format = "%^a %d %^b")
  date = self.eventdate || self.showtime
  date.strftime(format) if date
end
event_time(format = "%l:%M %p") click to toggle source

Returns a stringified version of the event time if the event has a showtime. Takes an optional strftime string as an argument for formatting.

# File lib/gigatools/gigatools_event.rb, line 44
def event_time(format = "%l:%M %p")
  self.showtime.strftime(format) if self.showtime
end
event_url() click to toggle source

Returns gigatools user url string

# File lib/gigatools/gigatools_event.rb, line 49
def event_url
  "http://gigs.gigatools.com/gig/#{self.id}"
end
venue_location() click to toggle source

Returns the city and state/country for an event if available

# File lib/gigatools/gigatools_event.rb, line 29
def venue_location
  major_geo = self.state || self.country
  [self.city, major_geo].compact.join(", ")
end