Class: EmptySpace
- Inherits:
-
Object
- Object
- EmptySpace
- Defined in:
- lib/space.rb
Instance Attribute Summary collapse
-
#color ⇒ Object
readonly
Returns the value of attribute color.
Instance Method Summary collapse
- #empty? ⇒ Boolean
- #enemy_of?(piece) ⇒ Boolean
- #friend_of?(piece) ⇒ Boolean
-
#initialize(x, y) ⇒ EmptySpace
constructor
A new instance of EmptySpace.
- #place_on(board) ⇒ Object
- #remove_from(board) ⇒ Object
- #to_coord ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(x, y) ⇒ EmptySpace
Returns a new instance of EmptySpace.
4 5 6 7 |
# File 'lib/space.rb', line 4 def initialize(x,y) @x, @y = x, y @color = :none end |
Instance Attribute Details
#color ⇒ Object (readonly)
Returns the value of attribute color.
3 4 5 |
# File 'lib/space.rb', line 3 def color @color end |
Instance Method Details
#empty? ⇒ Boolean
17 18 19 |
# File 'lib/space.rb', line 17 def empty? color == :none end |
#enemy_of?(piece) ⇒ Boolean
21 22 23 |
# File 'lib/space.rb', line 21 def enemy_of?(piece) false end |
#friend_of?(piece) ⇒ Boolean
25 26 27 |
# File 'lib/space.rb', line 25 def friend_of?(piece) false end |
#place_on(board) ⇒ Object
9 10 11 |
# File 'lib/space.rb', line 9 def place_on(board) board.board[@y][@x] = self end |
#remove_from(board) ⇒ Object
13 14 15 |
# File 'lib/space.rb', line 13 def remove_from(board) board.board[@y][@x] = EmptySpace.new(@x, @y) end |
#to_coord ⇒ Object
29 30 31 |
# File 'lib/space.rb', line 29 def to_coord [@x, @y] end |
#to_s ⇒ Object
33 34 35 |
# File 'lib/space.rb', line 33 def to_s (@x + @y) % 2 == 0 ? "__" : "##" end |