Class: CLI

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

Overview

The CLI is the ‘session’ created by the main class, managing arguments passed in and housing methods for scraping and downloading shows.

Instance Method Summary collapse

Constructor Details

#initialize(version, args) ⇒ CLI

Returns a new instance of CLI.



11
12
13
14
15
16
17
18
# File 'lib/deadlist/cli.rb', line 11

def initialize(version, args)
    @version = version
    @args = {}
    @show = nil

    startup_text
    parse_arguments(args)
end

Instance Method Details

#create_showObject

Creates new show object with link given populated with metadata and track details



21
22
23
24
25
26
27
28
# File 'lib/deadlist/cli.rb', line 21

def create_show
    extracted_id = extract_show_id(@args[:id])
    @show = Show.new(extracted_id, @args[:format])

    puts "\n💿 #{@show.name} - #{@show.tracks.length} tracks found!"
rescue => e
    puts "\n❌ Scraping failed: #{e.message}"
end

#download_showObject

Validates format isn’t for test, and passes directory + format arguments to the download method of a Show



31
32
33
34
35
36
37
38
39
40
# File 'lib/deadlist/cli.rb', line 31

def download_show
    if @args[:format] == "test"
      puts "Test Download, skipping"   
    else
        download_directory = setup_directories(@show)
        @show.download_tracks(download_directory)
    end
rescue => e
    puts "\n❌ Download failed: #{e.message}"
end