Class: EdmTrain::Event
- Inherits:
-
Object
- Object
- EdmTrain::Event
- Defined in:
- lib/edm_train/events.rb
Overview
Event object
Instance Attribute Summary collapse
-
#ages ⇒ Object
readonly
Returns the value of attribute ages.
-
#artists ⇒ Array<Artist>
readonly
Returns an array of artists performing at the event.
-
#date ⇒ Date
readonly
the date of the event.
-
#id ⇒ Integer
readonly
the event ID.
-
#link ⇒ String
readonly
the link to the event on EdmTrain.
-
#venue ⇒ Venue
readonly
the venue of the event.
Instance Method Summary collapse
-
#artist_names ⇒ Array<String>
Returns an array of artist names performing at the event.
-
#created_at ⇒ DateTime
Returns a string representation of the event for event searching.
-
#electronic? ⇒ Boolean
Returns true if the event is an electronic music event.
-
#end_time ⇒ DateTime
Returns the end time of the event.
-
#festival? ⇒ Boolean
Returns true if the event is a festival.
-
#initialize(raw_event) ⇒ Event
constructor
A new instance of Event.
-
#live_stream? ⇒ Boolean
Returns true if the event is a livestream.
-
#name ⇒ String
Returns the name of the event.
-
#other_genre? ⇒ Boolean
Returns true if the event is an other genre event.
-
#start_time ⇒ DateTime
Returns the start time of the event.
-
#to_s ⇒ String
Returns a string representation of the event.
Constructor Details
#initialize(raw_event) ⇒ Event
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
#ages ⇒ Object (readonly)
Returns the value of attribute ages.
39 40 41 |
# File 'lib/edm_train/events.rb', line 39 def ages @ages end |
#artists ⇒ Array<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 |
#date ⇒ Date (readonly)
the date of the event
38 39 40 |
# File 'lib/edm_train/events.rb', line 38 def date @date end |
#id ⇒ Integer (readonly)
the event ID
38 39 40 |
# File 'lib/edm_train/events.rb', line 38 def id @id end |
#link ⇒ String (readonly)
the link to the event on EdmTrain
38 39 40 |
# File 'lib/edm_train/events.rb', line 38 def link @link end |
#venue ⇒ Venue (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_names ⇒ Array<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_at ⇒ DateTime
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_time ⇒ DateTime
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 |
#name ⇒ String
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_time ⇒ DateTime
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_s ⇒ String
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 |