class StudioGame::Movie
Attributes
movie_type[R]
rank[R]
title[R]
Public Class Methods
from_csv(line)
click to toggle source
# File lib/movie.rb, line 17 def self.from_csv(line) name, rank, movie_type = line.split(",") Movie.new(name, rank, movie_type) end
new(title, rank=0, movie_type=:two_d)
click to toggle source
# File lib/movie.rb, line 8 def initialize(title, rank=0, movie_type=:two_d) @title = title.capitalize @rank = Integer(rank) @movie_type = if movie_type.nil? :two_d else movie_type end end
Public Instance Methods
<=>(other_movie)
click to toggle source
# File lib/movie.rb, line 39 def <=>(other_movie) other_movie.rank <=> rank end
hit?()
click to toggle source
# File lib/movie.rb, line 27 def hit? @rank > 10 end
play()
click to toggle source
# File lib/movie.rb, line 30 def play "Playing movie #{@title}, that is having rank : #{@rank}" end
t_down()
click to toggle source
# File lib/movie.rb, line 24 def t_down @rank -= 1 end
t_up()
click to toggle source
# File lib/movie.rb, line 21 def t_up @rank += 1 end
to_csv()
click to toggle source
# File lib/movie.rb, line 33 def to_csv "#{title},#{rank}" end
to_s()
click to toggle source
# File lib/movie.rb, line 36 def to_s "Movie #{@title}, that is having rank : #{@rank}, movie_type: #{movie_type}" end