Class: WhatsOnNetflix::List
- Inherits:
-
Object
- Object
- WhatsOnNetflix::List
- Defined in:
- lib/whats_on_netflix/list.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#display_title ⇒ Object
Returns the value of attribute display_title.
-
#genre ⇒ Object
Returns the value of attribute genre.
-
#plot ⇒ Object
Returns the value of attribute plot.
-
#stars ⇒ Object
Returns the value of attribute stars.
-
#title ⇒ Object
Returns the value of attribute title.
-
#year ⇒ Object
Returns the value of attribute year.
Class Method Summary collapse
- .add_movies ⇒ Object
- .create_from_array(array) ⇒ Object
-
.current_month ⇒ Object
used to generate current url for whats-on-netflix.com.
- .current_year ⇒ Object
- .item(input) ⇒ Object
-
.print_list ⇒ Object
CLI printers.
Instance Method Summary collapse
- #add_data_from_hash(hash) ⇒ Object
-
#initialize(display_title) ⇒ List
constructor
A new instance of List.
Constructor Details
#initialize(display_title) ⇒ List
Returns a new instance of List.
5 6 7 |
# File 'lib/whats_on_netflix/list.rb', line 5 def initialize(display_title) @display_title = display_title end |
Instance Attribute Details
#display_title ⇒ Object
Returns the value of attribute display_title.
3 4 5 |
# File 'lib/whats_on_netflix/list.rb', line 3 def display_title @display_title end |
#genre ⇒ Object
Returns the value of attribute genre.
3 4 5 |
# File 'lib/whats_on_netflix/list.rb', line 3 def genre @genre end |
#plot ⇒ Object
Returns the value of attribute plot.
3 4 5 |
# File 'lib/whats_on_netflix/list.rb', line 3 def plot @plot end |
#stars ⇒ Object
Returns the value of attribute stars.
3 4 5 |
# File 'lib/whats_on_netflix/list.rb', line 3 def stars @stars end |
#title ⇒ Object
Returns the value of attribute title.
3 4 5 |
# File 'lib/whats_on_netflix/list.rb', line 3 def title @title end |
#year ⇒ Object
Returns the value of attribute year.
3 4 5 |
# File 'lib/whats_on_netflix/list.rb', line 3 def year @year end |
Class Method Details
.add_movies ⇒ Object
9 10 11 |
# 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) ⇒ Object
13 14 15 16 17 18 19 20 |
# 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 ⇒ Object
used to generate current url for whats-on-netflix.com
31 32 33 |
# File 'lib/whats_on_netflix/list.rb', line 31 def self.current_month Date::MONTHNAMES[Date.today.month].downcase end |
.current_year ⇒ Object
35 36 37 |
# File 'lib/whats_on_netflix/list.rb', line 35 def self.current_year Date.today.year end |
.item(input) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 |
# 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 |
.print_list ⇒ Object
CLI printers
41 42 43 44 45 |
# 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 |
Instance Method Details
#add_data_from_hash(hash) ⇒ Object
22 23 24 25 26 27 |
# 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 |