Class: Show

Inherits:
Object
  • Object
show all
Defined in:
lib/deadlist/models/show.rb

Overview

Object to handle Show data and the array of Track objects to be used in downloading.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(download_url) ⇒ Show

Returns a new instance of Show.



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/deadlist/models/show.rb', line 5

def initialize(download_url)
    @show_link = download_url
    @name = nil
    @date = nil
    @location = nil
    @venue = nil
    @duration = nil
    @transferred_by = nil
    @available_formats = []
    @tracks = nil

    set_show_info
end

Instance Attribute Details

#available_formatsObject (readonly)

Returns the value of attribute available_formats.



3
4
5
# File 'lib/deadlist/models/show.rb', line 3

def available_formats
  @available_formats
end

#dateObject (readonly)

Returns the value of attribute date.



3
4
5
# File 'lib/deadlist/models/show.rb', line 3

def date
  @date
end

#durationObject (readonly)

Returns the value of attribute duration.



3
4
5
# File 'lib/deadlist/models/show.rb', line 3

def duration
  @duration
end

#locationObject (readonly)

Returns the value of attribute location.



3
4
5
# File 'lib/deadlist/models/show.rb', line 3

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/deadlist/models/show.rb', line 3

def name
  @name
end

#tracksObject (readonly)

Returns the value of attribute tracks.



3
4
5
# File 'lib/deadlist/models/show.rb', line 3

def tracks
  @tracks
end

#transferred_byObject (readonly)

Returns the value of attribute transferred_by.



3
4
5
# File 'lib/deadlist/models/show.rb', line 3

def transferred_by
  @transferred_by
end

#venueObject (readonly)

Returns the value of attribute venue.



3
4
5
# File 'lib/deadlist/models/show.rb', line 3

def venue
  @venue
end

Instance Method Details

#download_tracks(path, format) ⇒ Object

Initializes a Downloader and passes track details



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/deadlist/models/show.rb', line 25

def download_tracks(path, format)
    dl = Downloader.new(path, format)

    @tracks.each do |track|
        track_link = track.url_for_format(format)

        dl.get(track.pos, track.name, track_link)

        puts "⚡️ #{track.pos} - #{track.name} downloaded successfully"
    end
end

#has_format?(requested_format) ⇒ Boolean

Returns whether or not a given format is available for this show

Returns:

  • (Boolean)


20
21
22
# File 'lib/deadlist/models/show.rb', line 20

def has_format?(requested_format)
  @tracks[0].has_format?(requested_format)
end