Class: Sashite::Feen::Styles
- Inherits:
-
Object
- Object
- Sashite::Feen::Styles
- Defined in:
- lib/sashite/feen/styles.rb
Overview
Immutable representation of game styles and active player.
Stores the style identifiers (SIN) for both players, with the active player’s style indicating whose turn it is to move. The case of each style identifier indicates which player uses it (uppercase = first player, lowercase = second player).
Instance Attribute Summary collapse
-
#active ⇒ Object
readonly
Style identifier of the active player (to move).
-
#inactive ⇒ Object
readonly
Style identifier of the inactive player (waiting).
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
(also: #eql?)
Compare two styles for equality.
-
#hash ⇒ Integer
Generate hash code for styles.
-
#initialize(active, inactive) ⇒ Styles
constructor
Create a new immutable Styles object.
-
#to_s ⇒ String
Convert styles to their FEEN string representation.
Constructor Details
#initialize(active, inactive) ⇒ Styles
Create a new immutable Styles object.
34 35 36 37 38 39 |
# File 'lib/sashite/feen/styles.rb', line 34 def initialize(active, inactive) @active = active @inactive = inactive freeze end |
Instance Attribute Details
#active ⇒ Object (readonly)
Returns Style identifier of the active player (to move).
16 17 18 |
# File 'lib/sashite/feen/styles.rb', line 16 def active @active end |
#inactive ⇒ Object (readonly)
Returns Style identifier of the inactive player (waiting).
19 20 21 |
# File 'lib/sashite/feen/styles.rb', line 19 def inactive @inactive end |
Instance Method Details
#==(other) ⇒ Boolean Also known as: eql?
Compare two styles for equality.
56 57 58 59 60 |
# File 'lib/sashite/feen/styles.rb', line 56 def ==(other) other.is_a?(Styles) && active == other.active && inactive == other.inactive end |
#hash ⇒ Integer
Generate hash code for styles.
67 68 69 |
# File 'lib/sashite/feen/styles.rb', line 67 def hash [active, inactive].hash end |