Class: WhatToWatch::CLI
- Inherits:
-
Object
- Object
- WhatToWatch::CLI
- Defined in:
- lib/what_to_watch/cli.rb
Instance Attribute Summary collapse
-
#input ⇒ Object
Returns the value of attribute input.
-
#streaming_services ⇒ Object
Returns the value of attribute streaming_services.
Instance Method Summary collapse
- #exit ⇒ Object
-
#exit? ⇒ Boolean
CLI Logic Methods.
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #invalid_command ⇒ Object
- #item_options ⇒ Object
-
#main_commands ⇒ Object
CLI Dialogue Methods.
- #options ⇒ Object
- #start ⇒ Object
- #valid_number?(array) ⇒ Boolean
- #which_streaming_services ⇒ Object
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/what_to_watch/cli.rb', line 4 def initialize @input = "" @streaming_services = {netflix: "n", amazon_prime: "n", hbo_now: "n", hulu: "n", showtime: "n"} puts "==========================================" puts %q[ __ ___ _ _ \ \ / / |__ __ _| |_ | |_ ___ \ \ /\ / /| '_ \ / _` | __| | __/ _ \ \ V V / | | | | (_| | |_ | || (_) | __ \_/\_/ _|_| |_|\__,_|\__| \__\___/ \ \ / /_ _| |_ ___| |__ \ \ /\ / / _` | __/ __| '_ \ \ V V / (_| | || (__| | | | \_/\_/ \__,_|\__\___|_| |_| ] puts "==========================================" puts "" puts "Welcome to What To Watch!" puts "" which_streaming_services end |
Instance Attribute Details
#input ⇒ Object
Returns the value of attribute input.
2 3 4 |
# File 'lib/what_to_watch/cli.rb', line 2 def input @input end |
#streaming_services ⇒ Object
Returns the value of attribute streaming_services.
2 3 4 |
# File 'lib/what_to_watch/cli.rb', line 2 def streaming_services @streaming_services end |
Instance Method Details
#exit ⇒ Object
161 162 163 164 165 166 |
# File 'lib/what_to_watch/cli.rb', line 161 def exit puts "" puts "**********************************************************" puts "See You Next Time for More Great Movie/TV Recommendations!" puts "**********************************************************" end |
#exit? ⇒ Boolean
CLI Logic Methods
247 248 249 |
# File 'lib/what_to_watch/cli.rb', line 247 def exit? @input.downcase == "exit" end |
#invalid_command ⇒ Object
153 154 155 156 157 158 159 |
# File 'lib/what_to_watch/cli.rb', line 153 def invalid_command puts "" puts "I'm sorry, I don't recognize that Command." puts "Please Try Again" puts "" @input = gets.strip.downcase end |
#item_options ⇒ Object
139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/what_to_watch/cli.rb', line 139 def puts "" puts "-------" puts "OPTIONS" puts "-------" puts "Enter y to Get Info/Details for Another Selection" puts "Enter n to Go Back to MAIN MENU" puts "" puts "Exit: Type exit" puts "---------------" puts "" @input = gets.strip.downcase end |
#main_commands ⇒ Object
CLI Dialogue Methods
111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/what_to_watch/cli.rb', line 111 def main_commands puts "" puts "---------" puts "MAIN MENU:" puts "---------" puts "1. Enter 1 to see the Best-Reviewed MOVIES you can stream now." puts "2. Enter 2 to see the Best-Reviewed TELEVISION you can stream now." puts "3. Enter 3 to see Recently-Added MOVIES/TELEVISION you can stream now." puts "" puts "Exit: Type exit" puts "---------------" puts "" @input = gets.strip end |
#options ⇒ Object
126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/what_to_watch/cli.rb', line 126 def puts "" puts "-------" puts "OPTIONS:" puts "-------" puts "Enter The Number of the Selection to See Details and Information." puts "" puts "Exit: Type exit" puts "---------------" puts "" @input = gets.strip end |
#start ⇒ Object
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 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/what_to_watch/cli.rb', line 27 def start while !exit? main_commands while !exit? case @input when "1" WhatToWatch::BestMovies.add_shows WhatToWatch::BestMovies.list(@streaming_services) while !exit? if valid_number?(WhatToWatch::BestMovies.all) WhatToWatch::BestMovies.print_item(@input) while !exit? if @input == "y" break elsif @input == "n" WhatToWatch::BestMovies.reset! start else invalid_command end end else invalid_command end end when "2" WhatToWatch::BestTV.add_shows WhatToWatch::BestTV.list(@streaming_services) while !exit? if valid_number?(WhatToWatch::BestTV.all) WhatToWatch::BestTV.print_item(@input) while !exit? if @input == "y" break elsif @input == "n" WhatToWatch::BestTV.reset! start else invalid_command end end else invalid_command end end when "3" WhatToWatch::RecentlyAdded.add_shows WhatToWatch::RecentlyAdded.list(@streaming_services) while !exit? if valid_number?(WhatToWatch::RecentlyAdded.all) WhatToWatch::RecentlyAdded.print_item(@input) while !exit? if @input == "y" break elsif @input == "n" WhatToWatch::RecentlyAdded.reset! start else invalid_command end end else invalid_command end end else invalid_command end end end exit end |
#valid_number?(array) ⇒ Boolean
251 252 253 |
# File 'lib/what_to_watch/cli.rb', line 251 def valid_number?(array) @input.to_i.between?(1, array.size) end |
#which_streaming_services ⇒ Object
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
# File 'lib/what_to_watch/cli.rb', line 168 def which_streaming_services puts "" puts "Which Streaming Services do You Have Access To?" puts "" puts "Please Enter y or n to Answer each Question:" puts "1. Do You have Netflix?" @input = gets.strip.downcase while !exit? if @input == "y" @streaming_services[:netflix] = "y" break elsif @input == "n" @streaming_services[:netflix] = "n" break else invalid_command end end puts "2. Do You have Amazon Prime?" @input = gets.strip.downcase while !exit? if @input == "y" @streaming_services[:amazon_prime] = "y" break elsif @input == "n" @streaming_services[:amazon_prime] = "n" break else invalid_command end end puts "3. Do You have HBO?" @input = gets.strip.downcase while !exit? if @input == "y" @streaming_services[:hbo_now] = "y" break elsif @input == "n" @streaming_services[:hbo_now] = "n" break else invalid_command end end puts "4. Do You have HULU?" @input = gets.strip.downcase while !exit? if @input == "y" @streaming_services[:hulu] = "y" break elsif @input == "n" @streaming_services[:hulu] = "n" break else invalid_command end end puts "5. Do You have Showtime?" @input = gets.strip.downcase while !exit? if @input == "y" @streaming_services[:showtime] = "y" break elsif @input == "n" @streaming_services[:showtime] = "n" break else invalid_command end end end |