Sha256: 0693c16d7683ad4f765b820443cb4b977cd5dfc3159195a494dee981c7601fcd

Contents?: true

Size: 1.73 KB

Versions: 6

Compression:

Stored size: 1.73 KB

Contents

module WhatsOnNetflix
    class List
        attr_accessor:display_title, :title, :year, :genre, :stars, :plot
        
        def initialize(display_title)
            @display_title = display_title
        end
        
        def self.add_movies
            self.create_from_array(WhatsOnNetflix::Scraper.scrape_title_list(self.list_url))
        end
        
        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
        
        def add_data_from_hash(hash)
            self.year = hash[:year]
            self.genre = hash[:genre]
            self.stars = hash[:stars]
            self.plot = hash[:plot]
        end
        
        ### used to generate current url for whats-on-netflix.com
        
        def self.current_month
            Date::MONTHNAMES[Date.today.month].downcase
        end
        
        def self.current_year
            Date.today.year
        end
        
        ### CLI printers
        
        def self.print_list
            self.all.each_with_index do |movie, index|
                puts "#{index + 1}. #{movie.display_title}"
            end
        end
        
        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
        
    end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
whats-on-netflix-0.1.7 lib/whats_on_netflix/list.rb
whats-on-netflix-0.1.5 lib/whats_on_netflix/list.rb
whats-on-netflix-0.1.4 lib/whats_on_netflix/list.rb
whats-on-netflix-0.1.3 lib/whats_on_netflix/list.rb
whats-on-netflix-0.1.2 lib/whats_on_netflix/list.rb
whats-on-netflix-0.1.1 lib/whats_on_netflix/list.rb