Class: CLI
- Inherits:
-
Object
- Object
- CLI
- 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
-
#create_show ⇒ Object
Creates new show object with link given populated with metadata and track details.
-
#download_show ⇒ Object
Validates format isn’t for test, and passes directory + format arguments to the download method of a Show.
-
#initialize(version, args) ⇒ CLI
constructor
A new instance of CLI.
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_show ⇒ Object
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_show ⇒ Object
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 |