Class: Sashite::Feen::Position::StyleTurn
- Inherits:
-
Object
- Object
- Sashite::Feen::Position::StyleTurn
- Defined in:
- lib/sashite/feen/position/style_turn.rb
Overview
Represents the Style-Turn field (Field 3).
Encapsulates player styles and active player information.
Instance Attribute Summary collapse
-
#active_style ⇒ Sashite::Sin::Identifier
readonly
Active player’s style.
-
#inactive_style ⇒ Sashite::Sin::Identifier
readonly
Inactive player’s style.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
(also: #eql?)
Checks equality with another StyleTurn.
-
#first_to_move? ⇒ Boolean
Returns true if first player is to move.
-
#hash ⇒ Integer
Returns a hash code.
-
#initialize(active:, inactive:) ⇒ StyleTurn
constructor
Creates a new StyleTurn instance.
-
#second_to_move? ⇒ Boolean
Returns true if second player is to move.
-
#to_s ⇒ String
Returns the canonical string representation.
Constructor Details
#initialize(active:, inactive:) ⇒ StyleTurn
Creates a new StyleTurn instance.
29 30 31 32 33 34 |
# File 'lib/sashite/feen/position/style_turn.rb', line 29 def initialize(active:, inactive:) @active_style = active @inactive_style = inactive freeze end |
Instance Attribute Details
#active_style ⇒ Sashite::Sin::Identifier (readonly)
Returns Active player’s style.
20 21 22 |
# File 'lib/sashite/feen/position/style_turn.rb', line 20 def active_style @active_style end |
#inactive_style ⇒ Sashite::Sin::Identifier (readonly)
Returns Inactive player’s style.
23 24 25 |
# File 'lib/sashite/feen/position/style_turn.rb', line 23 def inactive_style @inactive_style end |
Instance Method Details
#==(other) ⇒ Boolean Also known as: eql?
Checks equality with another StyleTurn.
61 62 63 64 65 |
# File 'lib/sashite/feen/position/style_turn.rb', line 61 def ==(other) return false unless self.class === other active_style == other.active_style && inactive_style == other.inactive_style end |
#first_to_move? ⇒ Boolean
Returns true if first player is to move.
39 40 41 |
# File 'lib/sashite/feen/position/style_turn.rb', line 39 def first_to_move? active_style.side == :first end |
#hash ⇒ Integer
Returns a hash code.
72 73 74 |
# File 'lib/sashite/feen/position/style_turn.rb', line 72 def hash [active_style, inactive_style].hash end |
#second_to_move? ⇒ Boolean
Returns true if second player is to move.
46 47 48 |
# File 'lib/sashite/feen/position/style_turn.rb', line 46 def second_to_move? active_style.side == :second end |
#to_s ⇒ String
Returns the canonical string representation.
53 54 55 |
# File 'lib/sashite/feen/position/style_turn.rb', line 53 def to_s "#{active_style}#{Constants::SEGMENT_SEPARATOR}#{inactive_style}" end |