Class: PGN::Move
- Inherits:
-
Object
- Object
- PGN::Move
- Defined in:
- lib/pgn/move.rb
Overview
Move knows how to parse a move string in standard algebraic notation to extract all relevant information.
Constant Summary collapse
- SAN_REGEX =
A regular expression for matching moves in standard algebraic notation
%r{ (?<piece> [BKNQR] ){0} (?<destination> [a-h][1-8] ){0} (?<promotion> =[BNQR] ){0} (?<check> [#+] ){0} (?<capture> x ){0} (?<disambiguation> [a-h]?[1-8]? ){0} (?<castle> O-O(-O)? ){0} (?<normal> \g<piece>? \g<disambiguation> \g<capture>? \g<destination> \g<promotion>? ){0} \A (\g<castle> | \g<normal>) \g<check>? \z }x
Instance Attribute Summary collapse
-
#capture ⇒ String?
Whether the move is a capture.
-
#castle ⇒ String?
The castle string if applicable.
-
#check ⇒ String?
Whether the move results in check or mate.
-
#destination ⇒ String?
The destination square of the piece.
-
#disambiguation ⇒ String?
The disambiguation string if there is one.
-
#piece ⇒ String?
The piece being moved.
-
#player ⇒ Symbol
The current player.
-
#promotion ⇒ String?
The promotion piece, if applicable.
-
#san ⇒ String
The move string.
Instance Method Summary collapse
-
#black? ⇒ Boolean
Whether it’s black’s turn.
-
#check? ⇒ Boolean
Whether the move results in check.
-
#checkmate? ⇒ Boolean
Whether the move results in checkmate.
-
#initialize(move, player) ⇒ Move
constructor
A new instance of Move.
-
#pawn? ⇒ Boolean
Whether the piece being moved is a pawn.
-
#white? ⇒ Boolean
Whether it’s white’s turn.
Constructor Details
#initialize(move, player) ⇒ Move
Returns a new instance of Move.
91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/pgn/move.rb', line 91 def initialize(move, player) self.player = player self.san = move match = move.match(SAN_REGEX) match.names.each do |name| if self.respond_to?(name) self.send("#{name}=", match[name]) end end end |
Instance Attribute Details
#capture ⇒ String?
Returns whether the move is a capture.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/pgn/move.rb', line 58 class Move attr_accessor :san, :player attr_accessor :piece, :destination, :promotion, :check, :capture, :disambiguation, :castle # A regular expression for matching moves in standard algebraic # notation # SAN_REGEX = %r{ (?<piece> [BKNQR] ){0} (?<destination> [a-h][1-8] ){0} (?<promotion> =[BNQR] ){0} (?<check> [#+] ){0} (?<capture> x ){0} (?<disambiguation> [a-h]?[1-8]? ){0} (?<castle> O-O(-O)? ){0} (?<normal> \g<piece>? \g<disambiguation> \g<capture>? \g<destination> \g<promotion>? ){0} \A (\g<castle> | \g<normal>) \g<check>? \z }x # @param move [String] the move in SAN # @param player [Symbol] the player making the move # @example # PGN::Move.new("e4", :white) # def initialize(move, player) self.player = player self.san = move match = move.match(SAN_REGEX) match.names.each do |name| if self.respond_to?(name) self.send("#{name}=", match[name]) end end end def piece=(val) return if san.match("O-O") val ||= "P" @piece = self.black? ? val.downcase : val end def promotion=(val) if val val.downcase! if self.black? @promotion = val.delete("=") end end def capture=(val) @capture = !!val end def disambiguation=(val) @disambiguation = (val == "" ? nil : val) end def castle=(val) if val @castle = "K" if val == "O-O" @castle = "Q" if val == "O-O-O" @castle.downcase! if self.black? end end # @return [Boolean] whether the move results in check # def check? self.check == "+" end # @return [Boolean] whether the move results in checkmate # def checkmate? self.check == "#" end # @return [Boolean] whether it's white's turn # def white? self.player == :white end # @return [Boolean] whether it's black's turn # def black? self.player == :black end # @return [Boolean] whether the piece being moved is a pawn # def pawn? ['P', 'p'].include?(self.piece) end end |
#castle ⇒ String?
Returns the castle string if applicable.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/pgn/move.rb', line 58 class Move attr_accessor :san, :player attr_accessor :piece, :destination, :promotion, :check, :capture, :disambiguation, :castle # A regular expression for matching moves in standard algebraic # notation # SAN_REGEX = %r{ (?<piece> [BKNQR] ){0} (?<destination> [a-h][1-8] ){0} (?<promotion> =[BNQR] ){0} (?<check> [#+] ){0} (?<capture> x ){0} (?<disambiguation> [a-h]?[1-8]? ){0} (?<castle> O-O(-O)? ){0} (?<normal> \g<piece>? \g<disambiguation> \g<capture>? \g<destination> \g<promotion>? ){0} \A (\g<castle> | \g<normal>) \g<check>? \z }x # @param move [String] the move in SAN # @param player [Symbol] the player making the move # @example # PGN::Move.new("e4", :white) # def initialize(move, player) self.player = player self.san = move match = move.match(SAN_REGEX) match.names.each do |name| if self.respond_to?(name) self.send("#{name}=", match[name]) end end end def piece=(val) return if san.match("O-O") val ||= "P" @piece = self.black? ? val.downcase : val end def promotion=(val) if val val.downcase! if self.black? @promotion = val.delete("=") end end def capture=(val) @capture = !!val end def disambiguation=(val) @disambiguation = (val == "" ? nil : val) end def castle=(val) if val @castle = "K" if val == "O-O" @castle = "Q" if val == "O-O-O" @castle.downcase! if self.black? end end # @return [Boolean] whether the move results in check # def check? self.check == "+" end # @return [Boolean] whether the move results in checkmate # def checkmate? self.check == "#" end # @return [Boolean] whether it's white's turn # def white? self.player == :white end # @return [Boolean] whether it's black's turn # def black? self.player == :black end # @return [Boolean] whether the piece being moved is a pawn # def pawn? ['P', 'p'].include?(self.piece) end end |
#check ⇒ String?
Returns whether the move results in check or mate.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/pgn/move.rb', line 58 class Move attr_accessor :san, :player attr_accessor :piece, :destination, :promotion, :check, :capture, :disambiguation, :castle # A regular expression for matching moves in standard algebraic # notation # SAN_REGEX = %r{ (?<piece> [BKNQR] ){0} (?<destination> [a-h][1-8] ){0} (?<promotion> =[BNQR] ){0} (?<check> [#+] ){0} (?<capture> x ){0} (?<disambiguation> [a-h]?[1-8]? ){0} (?<castle> O-O(-O)? ){0} (?<normal> \g<piece>? \g<disambiguation> \g<capture>? \g<destination> \g<promotion>? ){0} \A (\g<castle> | \g<normal>) \g<check>? \z }x # @param move [String] the move in SAN # @param player [Symbol] the player making the move # @example # PGN::Move.new("e4", :white) # def initialize(move, player) self.player = player self.san = move match = move.match(SAN_REGEX) match.names.each do |name| if self.respond_to?(name) self.send("#{name}=", match[name]) end end end def piece=(val) return if san.match("O-O") val ||= "P" @piece = self.black? ? val.downcase : val end def promotion=(val) if val val.downcase! if self.black? @promotion = val.delete("=") end end def capture=(val) @capture = !!val end def disambiguation=(val) @disambiguation = (val == "" ? nil : val) end def castle=(val) if val @castle = "K" if val == "O-O" @castle = "Q" if val == "O-O-O" @castle.downcase! if self.black? end end # @return [Boolean] whether the move results in check # def check? self.check == "+" end # @return [Boolean] whether the move results in checkmate # def checkmate? self.check == "#" end # @return [Boolean] whether it's white's turn # def white? self.player == :white end # @return [Boolean] whether it's black's turn # def black? self.player == :black end # @return [Boolean] whether the piece being moved is a pawn # def pawn? ['P', 'p'].include?(self.piece) end end |
#destination ⇒ String?
Returns the destination square of the piece.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/pgn/move.rb', line 58 class Move attr_accessor :san, :player attr_accessor :piece, :destination, :promotion, :check, :capture, :disambiguation, :castle # A regular expression for matching moves in standard algebraic # notation # SAN_REGEX = %r{ (?<piece> [BKNQR] ){0} (?<destination> [a-h][1-8] ){0} (?<promotion> =[BNQR] ){0} (?<check> [#+] ){0} (?<capture> x ){0} (?<disambiguation> [a-h]?[1-8]? ){0} (?<castle> O-O(-O)? ){0} (?<normal> \g<piece>? \g<disambiguation> \g<capture>? \g<destination> \g<promotion>? ){0} \A (\g<castle> | \g<normal>) \g<check>? \z }x # @param move [String] the move in SAN # @param player [Symbol] the player making the move # @example # PGN::Move.new("e4", :white) # def initialize(move, player) self.player = player self.san = move match = move.match(SAN_REGEX) match.names.each do |name| if self.respond_to?(name) self.send("#{name}=", match[name]) end end end def piece=(val) return if san.match("O-O") val ||= "P" @piece = self.black? ? val.downcase : val end def promotion=(val) if val val.downcase! if self.black? @promotion = val.delete("=") end end def capture=(val) @capture = !!val end def disambiguation=(val) @disambiguation = (val == "" ? nil : val) end def castle=(val) if val @castle = "K" if val == "O-O" @castle = "Q" if val == "O-O-O" @castle.downcase! if self.black? end end # @return [Boolean] whether the move results in check # def check? self.check == "+" end # @return [Boolean] whether the move results in checkmate # def checkmate? self.check == "#" end # @return [Boolean] whether it's white's turn # def white? self.player == :white end # @return [Boolean] whether it's black's turn # def black? self.player == :black end # @return [Boolean] whether the piece being moved is a pawn # def pawn? ['P', 'p'].include?(self.piece) end end |
#disambiguation ⇒ String?
Returns the disambiguation string if there is one.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/pgn/move.rb', line 58 class Move attr_accessor :san, :player attr_accessor :piece, :destination, :promotion, :check, :capture, :disambiguation, :castle # A regular expression for matching moves in standard algebraic # notation # SAN_REGEX = %r{ (?<piece> [BKNQR] ){0} (?<destination> [a-h][1-8] ){0} (?<promotion> =[BNQR] ){0} (?<check> [#+] ){0} (?<capture> x ){0} (?<disambiguation> [a-h]?[1-8]? ){0} (?<castle> O-O(-O)? ){0} (?<normal> \g<piece>? \g<disambiguation> \g<capture>? \g<destination> \g<promotion>? ){0} \A (\g<castle> | \g<normal>) \g<check>? \z }x # @param move [String] the move in SAN # @param player [Symbol] the player making the move # @example # PGN::Move.new("e4", :white) # def initialize(move, player) self.player = player self.san = move match = move.match(SAN_REGEX) match.names.each do |name| if self.respond_to?(name) self.send("#{name}=", match[name]) end end end def piece=(val) return if san.match("O-O") val ||= "P" @piece = self.black? ? val.downcase : val end def promotion=(val) if val val.downcase! if self.black? @promotion = val.delete("=") end end def capture=(val) @capture = !!val end def disambiguation=(val) @disambiguation = (val == "" ? nil : val) end def castle=(val) if val @castle = "K" if val == "O-O" @castle = "Q" if val == "O-O-O" @castle.downcase! if self.black? end end # @return [Boolean] whether the move results in check # def check? self.check == "+" end # @return [Boolean] whether the move results in checkmate # def checkmate? self.check == "#" end # @return [Boolean] whether it's white's turn # def white? self.player == :white end # @return [Boolean] whether it's black's turn # def black? self.player == :black end # @return [Boolean] whether the piece being moved is a pawn # def pawn? ['P', 'p'].include?(self.piece) end end |
#piece ⇒ String?
this is nil for castling
uppercase represents white, lowercase represents black
Returns the piece being moved.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/pgn/move.rb', line 58 class Move attr_accessor :san, :player attr_accessor :piece, :destination, :promotion, :check, :capture, :disambiguation, :castle # A regular expression for matching moves in standard algebraic # notation # SAN_REGEX = %r{ (?<piece> [BKNQR] ){0} (?<destination> [a-h][1-8] ){0} (?<promotion> =[BNQR] ){0} (?<check> [#+] ){0} (?<capture> x ){0} (?<disambiguation> [a-h]?[1-8]? ){0} (?<castle> O-O(-O)? ){0} (?<normal> \g<piece>? \g<disambiguation> \g<capture>? \g<destination> \g<promotion>? ){0} \A (\g<castle> | \g<normal>) \g<check>? \z }x # @param move [String] the move in SAN # @param player [Symbol] the player making the move # @example # PGN::Move.new("e4", :white) # def initialize(move, player) self.player = player self.san = move match = move.match(SAN_REGEX) match.names.each do |name| if self.respond_to?(name) self.send("#{name}=", match[name]) end end end def piece=(val) return if san.match("O-O") val ||= "P" @piece = self.black? ? val.downcase : val end def promotion=(val) if val val.downcase! if self.black? @promotion = val.delete("=") end end def capture=(val) @capture = !!val end def disambiguation=(val) @disambiguation = (val == "" ? nil : val) end def castle=(val) if val @castle = "K" if val == "O-O" @castle = "Q" if val == "O-O-O" @castle.downcase! if self.black? end end # @return [Boolean] whether the move results in check # def check? self.check == "+" end # @return [Boolean] whether the move results in checkmate # def checkmate? self.check == "#" end # @return [Boolean] whether it's white's turn # def white? self.player == :white end # @return [Boolean] whether it's black's turn # def black? self.player == :black end # @return [Boolean] whether the piece being moved is a pawn # def pawn? ['P', 'p'].include?(self.piece) end end |
#player ⇒ Symbol
Returns the current player.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/pgn/move.rb', line 58 class Move attr_accessor :san, :player attr_accessor :piece, :destination, :promotion, :check, :capture, :disambiguation, :castle # A regular expression for matching moves in standard algebraic # notation # SAN_REGEX = %r{ (?<piece> [BKNQR] ){0} (?<destination> [a-h][1-8] ){0} (?<promotion> =[BNQR] ){0} (?<check> [#+] ){0} (?<capture> x ){0} (?<disambiguation> [a-h]?[1-8]? ){0} (?<castle> O-O(-O)? ){0} (?<normal> \g<piece>? \g<disambiguation> \g<capture>? \g<destination> \g<promotion>? ){0} \A (\g<castle> | \g<normal>) \g<check>? \z }x # @param move [String] the move in SAN # @param player [Symbol] the player making the move # @example # PGN::Move.new("e4", :white) # def initialize(move, player) self.player = player self.san = move match = move.match(SAN_REGEX) match.names.each do |name| if self.respond_to?(name) self.send("#{name}=", match[name]) end end end def piece=(val) return if san.match("O-O") val ||= "P" @piece = self.black? ? val.downcase : val end def promotion=(val) if val val.downcase! if self.black? @promotion = val.delete("=") end end def capture=(val) @capture = !!val end def disambiguation=(val) @disambiguation = (val == "" ? nil : val) end def castle=(val) if val @castle = "K" if val == "O-O" @castle = "Q" if val == "O-O-O" @castle.downcase! if self.black? end end # @return [Boolean] whether the move results in check # def check? self.check == "+" end # @return [Boolean] whether the move results in checkmate # def checkmate? self.check == "#" end # @return [Boolean] whether it's white's turn # def white? self.player == :white end # @return [Boolean] whether it's black's turn # def black? self.player == :black end # @return [Boolean] whether the piece being moved is a pawn # def pawn? ['P', 'p'].include?(self.piece) end end |
#promotion ⇒ String?
Returns the promotion piece, if applicable.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/pgn/move.rb', line 58 class Move attr_accessor :san, :player attr_accessor :piece, :destination, :promotion, :check, :capture, :disambiguation, :castle # A regular expression for matching moves in standard algebraic # notation # SAN_REGEX = %r{ (?<piece> [BKNQR] ){0} (?<destination> [a-h][1-8] ){0} (?<promotion> =[BNQR] ){0} (?<check> [#+] ){0} (?<capture> x ){0} (?<disambiguation> [a-h]?[1-8]? ){0} (?<castle> O-O(-O)? ){0} (?<normal> \g<piece>? \g<disambiguation> \g<capture>? \g<destination> \g<promotion>? ){0} \A (\g<castle> | \g<normal>) \g<check>? \z }x # @param move [String] the move in SAN # @param player [Symbol] the player making the move # @example # PGN::Move.new("e4", :white) # def initialize(move, player) self.player = player self.san = move match = move.match(SAN_REGEX) match.names.each do |name| if self.respond_to?(name) self.send("#{name}=", match[name]) end end end def piece=(val) return if san.match("O-O") val ||= "P" @piece = self.black? ? val.downcase : val end def promotion=(val) if val val.downcase! if self.black? @promotion = val.delete("=") end end def capture=(val) @capture = !!val end def disambiguation=(val) @disambiguation = (val == "" ? nil : val) end def castle=(val) if val @castle = "K" if val == "O-O" @castle = "Q" if val == "O-O-O" @castle.downcase! if self.black? end end # @return [Boolean] whether the move results in check # def check? self.check == "+" end # @return [Boolean] whether the move results in checkmate # def checkmate? self.check == "#" end # @return [Boolean] whether it's white's turn # def white? self.player == :white end # @return [Boolean] whether it's black's turn # def black? self.player == :black end # @return [Boolean] whether the piece being moved is a pawn # def pawn? ['P', 'p'].include?(self.piece) end end |
#san ⇒ String
Returns the move string.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/pgn/move.rb', line 58 class Move attr_accessor :san, :player attr_accessor :piece, :destination, :promotion, :check, :capture, :disambiguation, :castle # A regular expression for matching moves in standard algebraic # notation # SAN_REGEX = %r{ (?<piece> [BKNQR] ){0} (?<destination> [a-h][1-8] ){0} (?<promotion> =[BNQR] ){0} (?<check> [#+] ){0} (?<capture> x ){0} (?<disambiguation> [a-h]?[1-8]? ){0} (?<castle> O-O(-O)? ){0} (?<normal> \g<piece>? \g<disambiguation> \g<capture>? \g<destination> \g<promotion>? ){0} \A (\g<castle> | \g<normal>) \g<check>? \z }x # @param move [String] the move in SAN # @param player [Symbol] the player making the move # @example # PGN::Move.new("e4", :white) # def initialize(move, player) self.player = player self.san = move match = move.match(SAN_REGEX) match.names.each do |name| if self.respond_to?(name) self.send("#{name}=", match[name]) end end end def piece=(val) return if san.match("O-O") val ||= "P" @piece = self.black? ? val.downcase : val end def promotion=(val) if val val.downcase! if self.black? @promotion = val.delete("=") end end def capture=(val) @capture = !!val end def disambiguation=(val) @disambiguation = (val == "" ? nil : val) end def castle=(val) if val @castle = "K" if val == "O-O" @castle = "Q" if val == "O-O-O" @castle.downcase! if self.black? end end # @return [Boolean] whether the move results in check # def check? self.check == "+" end # @return [Boolean] whether the move results in checkmate # def checkmate? self.check == "#" end # @return [Boolean] whether it's white's turn # def white? self.player == :white end # @return [Boolean] whether it's black's turn # def black? self.player == :black end # @return [Boolean] whether the piece being moved is a pawn # def pawn? ['P', 'p'].include?(self.piece) end end |
Instance Method Details
#black? ⇒ Boolean
Returns whether it’s black’s turn.
156 157 158 |
# File 'lib/pgn/move.rb', line 156 def black? self.player == :black end |
#check? ⇒ Boolean
Returns whether the move results in check.
138 139 140 |
# File 'lib/pgn/move.rb', line 138 def check? self.check == "+" end |
#checkmate? ⇒ Boolean
Returns whether the move results in checkmate.
144 145 146 |
# File 'lib/pgn/move.rb', line 144 def checkmate? self.check == "#" end |
#pawn? ⇒ Boolean
Returns whether the piece being moved is a pawn.
162 163 164 |
# File 'lib/pgn/move.rb', line 162 def pawn? ['P', 'p'].include?(self.piece) end |
#white? ⇒ Boolean
Returns whether it’s white’s turn.
150 151 152 |
# File 'lib/pgn/move.rb', line 150 def white? self.player == :white end |