Class: MovieGem::Movie

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Movie

Returns a new instance of Movie.



5
6
7
8
# File 'lib/movie_gem/movie.rb', line 5

def initialize(attributes = {})
    @title = attributes[:title]
    @synopsis = attributes[:synopsis] 
end

Instance Attribute Details

#synopsisObject

Returns the value of attribute synopsis.



3
4
5
# File 'lib/movie_gem/movie.rb', line 3

def synopsis
  @synopsis
end

#titleObject

Returns the value of attribute title.



3
4
5
# File 'lib/movie_gem/movie.rb', line 3

def title
  @title
end

Class Method Details

.allObject



9
10
11
# File 'lib/movie_gem/movie.rb', line 9

def self.all
    @@all ||= self.load 
end

.create_from_collection(movies_array) ⇒ Object



12
13
14
15
16
# File 'lib/movie_gem/movie.rb', line 12

def self.create_from_collection(movies_array)
    movies_array.collect do |movie_hash|
        Movie.new(movie_hash)
    end
end

.loadObject



17
18
19
# File 'lib/movie_gem/movie.rb', line 17

def self.load            
    create_from_collection(MovieGem::Scraper.scrape_movies)
end