Created
October 13, 2012 20:35
-
-
Save codeschool-courses/3886064 to your computer and use it in GitHub Desktop.
RubyBits II 6-4 - library.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Library | |
def initialize | |
@games = [] | |
end | |
def add_game(game) | |
@games << game | |
end | |
def find_by_name(name) | |
@games.detect { |game| game.name == name } | |
end | |
def find_by_tag(tag) | |
@games.select { |game| game.tags.include?(tag) } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment