class WhatsOnNetflix::List
Attributes
display_title[RW]
genre[RW]
plot[RW]
stars[RW]
title[RW]
year[RW]
Public Class Methods
add_movies()
click to toggle source
# File lib/whats_on_netflix/list.rb, line 9 def self.add_movies self.create_from_array(WhatsOnNetflix::Scraper.scrape_title_list(self.list_url)) end
create_from_array(array)
click to toggle source
# File lib/whats_on_netflix/list.rb, line 13 def self.create_from_array(array) array.each do |entry| movie = self.new(entry) new_title = entry.split("(") movie.title = new_title[0].strip self.all << movie end end
current_month()
click to toggle source
used to generate current url for whats-on-netflix.com
# File lib/whats_on_netflix/list.rb, line 31 def self.current_month Date::MONTHNAMES[Date.today.month].downcase end
current_year()
click to toggle source
# File lib/whats_on_netflix/list.rb, line 35 def self.current_year Date.today.year end
item(input)
click to toggle source
# File lib/whats_on_netflix/list.rb, line 47 def self.item(input) movie = self.all[input.to_i - 1] movie.add_data_from_hash(WhatsOnNetflix::Scraper.scrape_imdb_info(movie.title)) puts "" puts "---" puts "#{movie.title} - #{movie.year}" puts "#{movie.genre}" puts "Starring #{movie.stars}" puts "" puts "#{movie.plot}" movie end
new(display_title)
click to toggle source
# File lib/whats_on_netflix/list.rb, line 5 def initialize(display_title) @display_title = display_title end
print_list()
click to toggle source
CLI
printers
# File lib/whats_on_netflix/list.rb, line 41 def self.print_list self.all.each_with_index do |movie, index| puts "#{index + 1}. #{movie.display_title}" end end
Public Instance Methods
add_data_from_hash(hash)
click to toggle source
# File lib/whats_on_netflix/list.rb, line 22 def add_data_from_hash(hash) self.year = hash[:year] self.genre = hash[:genre] self.stars = hash[:stars] self.plot = hash[:plot] end