Created
October 13, 2012 20:33
-
-
Save codeschool-courses/3886056 to your computer and use it in GitHub Desktop.
RubyBits II 6-3 - game_dsl.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
LIBRARY = Library.new | |
def add_game(name, system = nil, year = nil, &block) | |
game = Game.new(name) | |
game.system(system) if system | |
game.year(year) if year | |
game.instance_eval(&block) if block_given? | |
LIBRARY.add_game(game) | |
end | |
def with_game(*names, &block) | |
names.each do |name| | |
game = LIBRARY.find_by_name(name) | |
game.instance_eval(&block) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment