Class: EdmTrain::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/edm_train/events.rb

Overview

Event object

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_event) ⇒ Event

Note:

This is not intended to be called directly

Returns a new instance of Event.



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/edm_train/events.rb', line 42

def initialize(raw_event)
  @id = raw_event['id']
  @link = raw_event['link']
  @date = Date.parse(raw_event['date'])
  @start_time = raw_event['startTime']
  @end_time = raw_event['endTime']
  @artists = raw_event['artistList'].map {|artist| EdmTrain::Artist.new(artist)}
  @venue = EdmTrain::Venue.new(raw_event['venue'])
  @created_at = raw_event['createdDate']
  @festival = raw_event['festivalInd']
  @electronic = raw_event['electronicMusicInd']
  @other_genre = raw_event['otherGenreInd']
  @live_stream = raw_event['liveStreamInd']
  @ages = raw_event['ages'] || ''
  @name = raw_event['name']
  @festival = raw_event['festivalInd']
  @electronic = raw_event['electronicMusicInd']
  @other_genre = raw_event['otherGenreInd']
end

Instance Attribute Details

#agesObject (readonly)

Returns the value of attribute ages.



39
40
41
# File 'lib/edm_train/events.rb', line 39

def ages
  @ages
end

#artistsArray<Artist> (readonly)

Returns an array of artists performing at the event



38
39
40
# File 'lib/edm_train/events.rb', line 38

def artists
  @artists
end

#dateDate (readonly)

the date of the event



38
39
40
# File 'lib/edm_train/events.rb', line 38

def date
  @date
end

#idInteger (readonly)

the event ID



38
39
40
# File 'lib/edm_train/events.rb', line 38

def id
  @id
end

the link to the event on EdmTrain



38
39
40
# File 'lib/edm_train/events.rb', line 38

def link
  @link
end

#venueVenue (readonly)

the venue of the event



38
39
40
# File 'lib/edm_train/events.rb', line 38

def venue
  @venue
end

Instance Method Details

#artist_namesArray<String>

Returns an array of artist names performing at the event



118
119
120
121
# File 'lib/edm_train/events.rb', line 118

def artist_names
  return "Unknown" unless @artists
  @artists.map(&:name)
end

#created_atDateTime

Returns a string representation of the event for event searching



64
65
66
# File 'lib/edm_train/events.rb', line 64

def created_at
  @created_at ? DateTime.parse(raw_event['createdDate']) : nil
end

#electronic?Boolean

Returns true if the event is an electronic music event



94
95
96
# File 'lib/edm_train/events.rb', line 94

def electronic?
  @electronic
end

#end_timeDateTime

Returns the end time of the event. This only applies to livestreams



88
89
90
# File 'lib/edm_train/events.rb', line 88

def end_time
  @end_time ? DateTime.parse(@end_time) : date
end

#festival?Boolean

Returns true if the event is a festival



106
107
108
# File 'lib/edm_train/events.rb', line 106

def festival?
  @festival
end

#live_stream?Boolean

Returns true if the event is a livestream



112
113
114
# File 'lib/edm_train/events.rb', line 112

def live_stream?
  @live_stream || venue.name.match?(/live ?stream/i)
end

#nameString

Returns the name of the event



76
77
78
# File 'lib/edm_train/events.rb', line 76

def name
  @name || @artists.map(&:name).join(', ')
end

#other_genre?Boolean

Returns true if the event is an other genre event



100
101
102
# File 'lib/edm_train/events.rb', line 100

def other_genre?
  @other_genre
end

#start_timeDateTime

Returns the start time of the event. This only applies to livestreams



82
83
84
# File 'lib/edm_train/events.rb', line 82

def start_time
  @start_time ? DateTime.parse(@start_time) : date
end

#to_sString

Returns a string representation of the event.



125
126
127
# File 'lib/edm_train/events.rb', line 125

def to_s
  "#{name} - #{artist_names.join(', ')} at #{venue.name}"
end