Class: RtTop100::Movie

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

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(movies_hash) ⇒ Movie

Returns a new instance of Movie.



7
8
9
10
11
12
# File 'lib/rt_top_100/movie.rb', line 7

def initialize(movies_hash)
  movies_hash.each do | attr, value |
    self.send("#{attr}=", value)
  end
  @@all << self
end

Instance Attribute Details

#audience_scoreObject

Returns the value of attribute audience_score.



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

def audience_score
  @audience_score
end

#critic_consensusObject

Returns the value of attribute critic_consensus.



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

def critic_consensus
  @critic_consensus
end

#directorObject

Returns the value of attribute director.



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

def director
  @director
end

#genreObject

Returns the value of attribute genre.



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

def genre
  @genre
end

#movie_urlObject

Returns the value of attribute movie_url.



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

def movie_url
  @movie_url
end

#ratingObject

Returns the value of attribute rating.



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

def rating
  @rating
end

#release_dateObject

Returns the value of attribute release_date.



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

def release_date
  @release_date
end

#synopsisObject

Returns the value of attribute synopsis.



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

def synopsis
  @synopsis
end

#titleObject

Returns the value of attribute title.



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

def title
  @title
end

#tomatometer_scoreObject

Returns the value of attribute tomatometer_score.



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

def tomatometer_score
  @tomatometer_score
end

Class Method Details

.allObject



21
22
23
# File 'lib/rt_top_100/movie.rb', line 21

def self.all
  @@all
end

.movies_release_after(year) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/rt_top_100/movie.rb', line 25

def self.movies_release_after(year)
  released_movies = @@all.each.with_index do | movie, rank |
    if movie.title[-5..-2].to_i >= year
    puts "#{rank+1}. #{movie.title}"
    end
  end
  released_movies
end

Instance Method Details

#add_details(details_hash) ⇒ Object



14
15
16
17
18
19
# File 'lib/rt_top_100/movie.rb', line 14

def add_details(details_hash)
  details_hash.each do | attr, value |
    self.send("#{attr}=", value)
  end
  self
end