Module: RetroCasts
- Extended by:
- CLI
- Defined in:
- lib/retro_casts.rb,
lib/retro_casts/cli.rb,
lib/retro_casts/episode.rb,
lib/retro_casts/version.rb,
lib/retro_casts/website.rb,
lib/retro_casts/rails_casts.rb,
lib/retro_casts/null_website.rb
Defined Under Namespace
Modules: CLI Classes: Episode, NullWebsite, RailsCasts, Website
Constant Summary collapse
- VERSION =
"0.1.2"
Class Method Summary collapse
Methods included from CLI
display, retro_welcome, welcome
Class Method Details
.start(klass: RetroCasts::RailsCasts) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/retro_casts.rb', line 16 def self.start(klass: RetroCasts::RailsCasts) retro_welcome welcome if !ARGV.empty? site = klass.new(search: ARGV.join(" ")) else site ||= klass.new end = "" exit_all_loops = false loop do break if exit_all_loops display("#" * 50) site.list_episodes puts "*** #{} ***" unless == "" = "" puts "Please select an option..." puts "Episodes: 1 to #{site.episodes.length} | home | search {search terms} | next | back | exit" print ">" input = $stdin.gets.chomp.split(" ") command = input.shift argument = input.join(" ") if integer?(command) && site.episode?(command.to_i) loop do episode = site.episode(command.to_i) site.show_episode_detail(command.to_i) puts "Type 'back' to go back, 'open' to open the episode in your browser, or 'exit' to exit." print ">" case $stdin.gets.chomp.downcase when "exit" exit_all_loops = true break when "back" break when "open" `open #{episode.link}` else puts "Please choose 'back' or 'open'." print ">" end end elsif command == nil = "Enter is not a valid selection." else case command.downcase when "home" puts "Going back to the homepage..." site.get_search(nil) when "search" puts "Searching for \"#{argument}\"..." site.get_search(argument) when "next" puts "Opening page #{site.page + 1}..." site.next_page when "back" puts "Opening page #{site.page - 1}..." site.prev_page when "exit" break else = "#{command} is not a valid selection." end end end end |