Class: WhatToWatch::Show

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

Direct Known Subclasses

BestMovies, BestTV, RecentlyAdded

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#castObject

Returns the value of attribute cast.



2
3
4
# File 'lib/what_to_watch/show.rb', line 2

def cast
  @cast
end

#descriptionObject

Returns the value of attribute description.



2
3
4
# File 'lib/what_to_watch/show.rb', line 2

def description
  @description
end

#genre_yearObject

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_serviceObject

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

#titleObject

Returns the value of attribute title.



2
3
4
# File 'lib/what_to_watch/show.rb', line 2

def title
  @title
end

#urlObject

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_showsObject



14
15
16
# File 'lib/what_to_watch/show.rb', line 14

def self.add_shows
  WhatToWatch::Scraper.scrape_vulture(self)
end


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


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