Class: Hand
- Inherits:
-
Object
- Object
- Hand
- Defined in:
- lib/mousevc_rock_paper_scissors/hand.rb
Instance Method Summary collapse
- #<(other) ⇒ Object
- #<=(other) ⇒ Object
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
- #>(other) ⇒ Object
- #>=(other) ⇒ Object
- #beats?(hand) ⇒ Boolean
- #compare(hand) ⇒ Object
- #ties?(hand) ⇒ Boolean
Instance Method Details
#<(other) ⇒ Object
9 10 11 |
# File 'lib/mousevc_rock_paper_scissors/hand.rb', line 9 def <(other) ! beats?(other) end |
#<=(other) ⇒ Object
17 18 19 |
# File 'lib/mousevc_rock_paper_scissors/hand.rb', line 17 def <=(other) ! beats?(other) || ties?(other) end |
#<=>(other) ⇒ Object
25 26 27 |
# File 'lib/mousevc_rock_paper_scissors/hand.rb', line 25 def <=>(other) self.compare(other) <=> other.compare(self) end |
#==(other) ⇒ Object
21 22 23 |
# File 'lib/mousevc_rock_paper_scissors/hand.rb', line 21 def ==(other) ties?(other) end |
#>(other) ⇒ Object
5 6 7 |
# File 'lib/mousevc_rock_paper_scissors/hand.rb', line 5 def >(other) beats?(other) end |
#>=(other) ⇒ Object
13 14 15 |
# File 'lib/mousevc_rock_paper_scissors/hand.rb', line 13 def >=(other) beats?(other) || ties?(other) end |
#beats?(hand) ⇒ Boolean
33 34 35 |
# File 'lib/mousevc_rock_paper_scissors/hand.rb', line 33 def beats?(hand) (self <=> hand) == 1 end |
#compare(hand) ⇒ Object
2 3 |
# File 'lib/mousevc_rock_paper_scissors/hand.rb', line 2 def compare(hand) end |
#ties?(hand) ⇒ Boolean
29 30 31 |
# File 'lib/mousevc_rock_paper_scissors/hand.rb', line 29 def ties?(hand) (self <=> hand) == 0 end |