Class: Sashite::Pan::Action::Pass
- Inherits:
-
Object
- Object
- Sashite::Pan::Action::Pass
- Includes:
- Singleton
- Defined in:
- lib/sashite/pan/action/pass.rb
Overview
Pass action class
Represents a pass action where the active player voluntarily ends their turn without performing any movement or transformation.
This class is implemented as a singleton since all pass actions are identical.
Format: “…”
Constant Summary collapse
- TYPE =
Action type
:pass- NOTATION =
Pass notation constant
"..."- ERROR_INVALID_PASS =
Error messages
"Invalid pass notation: %s"
Class Method Summary collapse
-
.parse(pan_string) ⇒ Pass
Parse a pass notation string into a Pass instance.
-
.valid?(pan_string) ⇒ Boolean
Check if a string represents a valid pass action.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
(also: #eql?)
Custom equality comparison.
-
#capture? ⇒ Boolean
Check if this is a capture action.
-
#destination ⇒ nil
Get the destination coordinate.
-
#drop? ⇒ Boolean
Check if this is a drop action.
-
#drop_action? ⇒ Boolean
Check if this is a drop action (drop or drop_capture).
-
#drop_capture? ⇒ Boolean
Check if this is a drop capture action.
-
#hash ⇒ Integer
Custom hash implementation for use in collections.
-
#modify? ⇒ Boolean
Check if this is a modify action.
-
#move? ⇒ Boolean
Check if this is a move action.
-
#movement? ⇒ Boolean
Check if this is a movement action.
-
#pass? ⇒ Boolean
Check if this is a pass action.
-
#piece ⇒ nil
Get the piece identifier.
-
#source ⇒ nil
Get the source coordinate.
-
#special? ⇒ Boolean
Check if this is a special action.
-
#static_capture? ⇒ Boolean
Check if this is a static capture action.
-
#to_s ⇒ String
Convert the action to its PAN string representation.
-
#transformation ⇒ nil
Get the transformation piece.
-
#type ⇒ Symbol
Get the action type.
Class Method Details
.parse(pan_string) ⇒ Pass
Parse a pass notation string into a Pass instance
48 49 50 51 52 |
# File 'lib/sashite/pan/action/pass.rb', line 48 def self.parse(pan_string) raise ::ArgumentError, format(ERROR_INVALID_PASS, pan_string) unless valid?(pan_string) instance end |
.valid?(pan_string) ⇒ Boolean
Check if a string represents a valid pass action
36 37 38 |
# File 'lib/sashite/pan/action/pass.rb', line 36 def self.valid?(pan_string) pan_string == NOTATION end |
Instance Method Details
#==(other) ⇒ Boolean Also known as: eql?
Custom equality comparison
173 174 175 |
# File 'lib/sashite/pan/action/pass.rb', line 173 def ==(other) other.equal?(self) end |
#capture? ⇒ Boolean
Check if this is a capture action
116 117 118 |
# File 'lib/sashite/pan/action/pass.rb', line 116 def capture? false end |
#destination ⇒ nil
Get the destination coordinate
71 72 73 |
# File 'lib/sashite/pan/action/pass.rb', line 71 def destination nil end |
#drop? ⇒ Boolean
Check if this is a drop action
137 138 139 |
# File 'lib/sashite/pan/action/pass.rb', line 137 def drop? false end |
#drop_action? ⇒ Boolean
Check if this is a drop action (drop or drop_capture)
165 166 167 |
# File 'lib/sashite/pan/action/pass.rb', line 165 def drop_action? false end |
#drop_capture? ⇒ Boolean
Check if this is a drop capture action
144 145 146 |
# File 'lib/sashite/pan/action/pass.rb', line 144 def drop_capture? false end |
#hash ⇒ Integer
Custom hash implementation for use in collections
183 184 185 |
# File 'lib/sashite/pan/action/pass.rb', line 183 def hash [self.class, TYPE].hash end |
#modify? ⇒ Boolean
Check if this is a modify action
151 152 153 |
# File 'lib/sashite/pan/action/pass.rb', line 151 def modify? false end |
#move? ⇒ Boolean
Check if this is a move action
109 110 111 |
# File 'lib/sashite/pan/action/pass.rb', line 109 def move? false end |
#movement? ⇒ Boolean
Check if this is a movement action
158 159 160 |
# File 'lib/sashite/pan/action/pass.rb', line 158 def movement? false end |
#pass? ⇒ Boolean
Check if this is a pass action
102 103 104 |
# File 'lib/sashite/pan/action/pass.rb', line 102 def pass? true end |
#piece ⇒ nil
Get the piece identifier
78 79 80 |
# File 'lib/sashite/pan/action/pass.rb', line 78 def piece nil end |
#source ⇒ nil
Get the source coordinate
64 65 66 |
# File 'lib/sashite/pan/action/pass.rb', line 64 def source nil end |
#special? ⇒ Boolean
Check if this is a special action
123 124 125 |
# File 'lib/sashite/pan/action/pass.rb', line 123 def special? false end |
#static_capture? ⇒ Boolean
Check if this is a static capture action
130 131 132 |
# File 'lib/sashite/pan/action/pass.rb', line 130 def static_capture? false end |
#to_s ⇒ String
Convert the action to its PAN string representation
95 96 97 |
# File 'lib/sashite/pan/action/pass.rb', line 95 def to_s NOTATION end |
#transformation ⇒ nil
Get the transformation piece
85 86 87 |
# File 'lib/sashite/pan/action/pass.rb', line 85 def transformation nil end |
#type ⇒ Symbol
Get the action type
57 58 59 |
# File 'lib/sashite/pan/action/pass.rb', line 57 def type TYPE end |