Created
December 3, 2008 00:21
-
-
Save vanpelt/31359 to your computer and use it in GitHub Desktop.
This file contains 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
fragments = [ | |
["The %s %s %s", | |
proc do |*args| | |
raise ArgumentError unless args.all{|a| a.respond_to?(:name) && a.respond_to?(:score)} | |
[args[0].name, args[0].score > args[1].score ? "beat the" : "won against", args[1].name] | |
end] | |
] | |
class Team | |
attr_reader :name, :score | |
def initialize(name, score) | |
@name = name | |
@score = score | |
end | |
end | |
fragments.map do |f| | |
f[0] % f[1].call(Team.new("Cubs", 10), Team.new("Bears",5)) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment