Last active
May 9, 2017 14:37
-
-
Save mvoto/d314ad904889e9eb9cd1d26b4c4e8c3b to your computer and use it in GitHub Desktop.
Revisions
-
mvoto revised this gist
May 9, 2017 . 1 changed file with 1 addition and 13 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -11,19 +11,7 @@ def wins_against?(other_move) send("beats_#{other_move.class.to_s.downcase}?") end def method_missing(args) false end end -
mvoto revised this gist
May 9, 2017 . 1 changed file with 33 additions and 11 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,24 +2,46 @@ class Game def self.play(move1, move2) return :tie if move1.class == move2.class move1.wins_against?(move2) end end class Base def wins_against?(other_move) send("beats_#{other_move.class.to_s.downcase}?") end def beats_rock? false end def beats_paper? false end def beats_scissors? false end def method_missing? false end end class Rock < Base def beats_scissors? true end end class Paper < Base def beats_rock? true end end class Scissors < Base def beats_paper? true end end -
mvoto created this gist
May 8, 2017 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ class Game def self.play(move1, move2) return :tie if move1.class == move2.class move1.beats?(move2) end end class Rock def beats?(other_move) other_move.is_a?(Scissors) end end class Paper def beats?(other_move) other_move.is_a?(Paper) end end class Scissors def beats?(other_move) other_move.is_a?(Rock) end end