Class: Movie
- Inherits:
-
Object
- Object
- Movie
- Defined in:
- lib/studio_game/movie.rb
Instance Attribute Summary collapse
-
#rank ⇒ Object
readonly
Returns the value of attribute rank.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(title, rank = 0) ⇒ Movie
constructor
A new instance of Movie.
- #normalized_rank ⇒ Object
- #thumbs_down ⇒ Object
- #thumbs_up ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(title, rank = 0) ⇒ Movie
5 6 7 8 |
# File 'lib/studio_game/movie.rb', line 5 def initialize(title, rank=0) @title = title.capitalize @rank = rank end |
Instance Attribute Details
#rank ⇒ Object (readonly)
Returns the value of attribute rank.
2 3 4 |
# File 'lib/studio_game/movie.rb', line 2 def rank @rank end |
#title ⇒ Object
Returns the value of attribute title.
3 4 5 |
# File 'lib/studio_game/movie.rb', line 3 def title @title end |
Instance Method Details
#normalized_rank ⇒ Object
10 11 12 |
# File 'lib/studio_game/movie.rb', line 10 def normalized_rank @rank/10 end |
#thumbs_down ⇒ Object
18 19 20 |
# File 'lib/studio_game/movie.rb', line 18 def thumbs_down @rank -= 1 end |
#thumbs_up ⇒ Object
14 15 16 |
# File 'lib/studio_game/movie.rb', line 14 def thumbs_up @rank += 1 end |
#to_s ⇒ Object
22 23 24 |
# File 'lib/studio_game/movie.rb', line 22 def to_s "#{@title} has a rank of #{rank}" end |