Class: WhatToWatch::Show
- Inherits:
-
Object
- Object
- WhatToWatch::Show
- Defined in:
- lib/what_to_watch/show.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#cast ⇒ Object
Returns the value of attribute cast.
-
#description ⇒ Object
Returns the value of attribute description.
-
#genre_year ⇒ Object
Returns the value of attribute genre_year.
-
#streaming_service ⇒ Object
Returns the value of attribute streaming_service.
-
#title ⇒ Object
Returns the value of attribute title.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
- .add_shows ⇒ Object
- .print_item(input) ⇒ Object
- .print_list(hash) ⇒ Object
-
.services(hash) ⇒ Object
Determine Display Based On User Input Recorded in CLI.streaming_services.
Instance Method Summary collapse
-
#initialize(title = "", streaming_service = "") ⇒ Show
constructor
WhatToWatch::BestMovies.add_shows WhatToWatch::BestMovies.list() “y”, amazon_prime: “y”, hbo_now: “y”, hulu: “y”, showtime: “y”.
Constructor Details
#initialize(title = "", streaming_service = "") ⇒ Show
WhatToWatch::BestMovies.add_shows WhatToWatch::BestMovies.list() “y”, amazon_prime: “y”, hbo_now: “y”, hulu: “y”, showtime: “y”
8 9 10 11 12 |
# File 'lib/what_to_watch/show.rb', line 8 def initialize(title="", streaming_service="") @title = title @streaming_service = streaming_service self.class.all << self end |
Instance Attribute Details
#cast ⇒ Object
Returns the value of attribute cast.
2 3 4 |
# File 'lib/what_to_watch/show.rb', line 2 def cast @cast end |
#description ⇒ Object
Returns the value of attribute description.
2 3 4 |
# File 'lib/what_to_watch/show.rb', line 2 def description @description end |
#genre_year ⇒ Object
Returns the value of attribute genre_year.
2 3 4 |
# File 'lib/what_to_watch/show.rb', line 2 def genre_year @genre_year end |
#streaming_service ⇒ Object
Returns the value of attribute streaming_service.
2 3 4 |
# File 'lib/what_to_watch/show.rb', line 2 def streaming_service @streaming_service end |
#title ⇒ Object
Returns the value of attribute title.
2 3 4 |
# File 'lib/what_to_watch/show.rb', line 2 def title @title end |
#url ⇒ Object
Returns the value of attribute url.
2 3 4 |
# File 'lib/what_to_watch/show.rb', line 2 def url @url end |
Class Method Details
.add_shows ⇒ Object
14 15 16 |
# File 'lib/what_to_watch/show.rb', line 14 def self.add_shows WhatToWatch::Scraper.scrape_vulture(self) end |
.print_item(input) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/what_to_watch/show.rb', line 46 def self.print_item(input) object = self.all[input.to_i-1] WhatToWatch::Scraper.scrape_imdb(object) puts "" puts "====================================" puts " #{object.title.upcase}" puts "====================================" puts "#{object.genre_year}" puts "" puts "*** Available on #{object.streaming_service.upcase} ***" puts "" object.cast.each{|role, people| puts "#{role} #{people}"} puts "" puts "---Description---" puts "" puts "#{object.description}" puts "[...]" puts "" puts "For more information" puts "" puts "===> #{object.url}" end |
.print_list(hash) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/what_to_watch/show.rb', line 31 def self.print_list(hash) self.all.each.with_index(1) do |object, index| if self.services(hash).include?(object.streaming_service) puts "" puts "Available! #{index}. #{object.title.upcase}. Watch Now on #{object.streaming_service}." puts "" else puts "" puts "Sorry..... #{index}. #{object.title.upcase}. Only on #{object.streaming_service}." puts "" end end end |
.services(hash) ⇒ Object
Determine Display Based On User Input Recorded in CLI.streaming_services
20 21 22 23 24 25 26 27 28 |
# File 'lib/what_to_watch/show.rb', line 20 def self.services(hash) services = hash.collect do |service, value| if value == "y" service.to_s.split('_').join(' ').capitalize end end services.compact! services end |