Class: Sashite::Feen::Position::Hands
- Inherits:
-
Object
- Object
- Sashite::Feen::Position::Hands
- Defined in:
- lib/sashite/feen/position/hands.rb
Overview
Represents the Hands field (Field 2).
Encapsulates off-board pieces held by each player.
Instance Attribute Summary collapse
-
#first ⇒ Hand
readonly
First player’s hand.
-
#second ⇒ Hand
readonly
Second player’s hand.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
(also: #eql?)
Checks equality with another Hands.
-
#hash ⇒ Integer
Returns a hash code.
-
#initialize(first:, second:) ⇒ Hands
constructor
Creates a new Hands instance.
-
#to_s ⇒ String
Returns the canonical string representation.
Constructor Details
Instance Attribute Details
#first ⇒ Hand (readonly)
Returns First player’s hand.
22 23 24 |
# File 'lib/sashite/feen/position/hands.rb', line 22 def first @first end |
#second ⇒ Hand (readonly)
Returns Second player’s hand.
25 26 27 |
# File 'lib/sashite/feen/position/hands.rb', line 25 def second @second end |
Instance Method Details
#==(other) ⇒ Boolean Also known as: eql?
Checks equality with another Hands.
49 50 51 52 53 |
# File 'lib/sashite/feen/position/hands.rb', line 49 def ==(other) return false unless self.class === other first == other.first && second == other.second end |
#hash ⇒ Integer
Returns a hash code.
60 61 62 |
# File 'lib/sashite/feen/position/hands.rb', line 60 def hash [first, second].hash end |
#to_s ⇒ String
Returns the canonical string representation.
41 42 43 |
# File 'lib/sashite/feen/position/hands.rb', line 41 def to_s "#{first}#{Constants::SEGMENT_SEPARATOR}#{second}" end |