Class: MailChess::Piece::Pawn
- Defined in:
- lib/mail_chess/pieces/pawn.rb
Overview
Represents a pawn chess piece.
Instance Attribute Summary
Attributes inherited from Piece
#board, #color, #html, #id, #type
Class Method Summary collapse
-
.new!(db, board, position, color) ⇒ Object
Overwrite superclass method.
Instance Method Summary collapse
-
#initialize(db, piece_id, board = nil) ⇒ Pawn
constructor
Calls the superclass.
Methods inherited from Piece
create_tables, #delete!, load!, need_to_create_tables?, #position, #save!
Constructor Details
#initialize(db, piece_id, board = nil) ⇒ Pawn
Calls the superclass.
11 12 13 14 15 |
# File 'lib/mail_chess/pieces/pawn.rb', line 11 def initialize db, piece_id, board = nil super db, piece_id, board @html = @color == :white ? '♙' : '♟' end |
Class Method Details
.new!(db, board, position, color) ⇒ Object
Overwrite superclass method.
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/mail_chess/pieces/pawn.rb', line 18 def self.new! db, board, position, color super db, board, position, color id = db[:pieces].insert(:type => 'pawn', :color => color.to_s, :position => position, :board_id => board.id) return Pawn.new db, id, board end |