Skip to content

Commit

Permalink
Add the different methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Have-Samuel committed Jun 29, 2022
1 parent a80ffe7 commit 85aae07
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions games.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,22 @@
require 'date'

class Game < Item
attr_accessor :multiplayer: true last_played_at

def initialize(title, author, publish_date, archeived: false, multiplayer: true, last_played_at)
super(title, publish_date)
@multiplayer = multiplayer
@last_played_at = DateTime.parse(last_played_at)
end

def can_be_archived?
return true if super && @last_played_at > '2years'

false
end

def to_hash
{ title: @title, @arthor: arthor publish_date: @publish_date.strftime('%Y-%m-%d'), multiplayer: true, @last_played_at }
end

end

0 comments on commit 85aae07

Please sign in to comment.