Class: RGnuchess::Move

Inherits:
Object
  • Object
show all
Defined in:
lib/rgnuchess.rb

Overview

A Move represents a possible chess move, relative to a given chess position. (Gnuchess gives simple moves, e.g. β€œe4” or β€œNa6”, so the same move string may mean something else with a different board position.)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mv, check, mate) ⇒ Move

Returns a new instance of Move.



74
75
76
# File 'lib/rgnuchess.rb', line 74

def initialize(mv,check,mate)
  @mv,@check,@mate = mv,check,mate
end

Instance Attribute Details

#checkObject

Returns the value of attribute check.



86
87
88
# File 'lib/rgnuchess.rb', line 86

def check
  @check
end

#mateObject

Returns the value of attribute mate.



86
87
88
# File 'lib/rgnuchess.rb', line 86

def mate
  @mate
end

#mvObject

Returns the value of attribute mv.



86
87
88
# File 'lib/rgnuchess.rb', line 86

def mv
  @mv
end

Class Method Details

.parse(str) ⇒ Object



71
72
73
# File 'lib/rgnuchess.rb', line 71

def Move.parse(str)
  Move.new( str.scan(/\w+/)[0], str=~/\+/, str=~/#/ )
end

Instance Method Details

#check?Boolean

Returns:

  • (Boolean)


83
84
85
# File 'lib/rgnuchess.rb', line 83

def check?
  @check
end

#checkmate?Boolean

Returns:

  • (Boolean)


80
81
82
# File 'lib/rgnuchess.rb', line 80

def checkmate?
  @mate
end

#to_sObject



77
78
79
# File 'lib/rgnuchess.rb', line 77

def to_s
  @mv
end