Adds .rvmrc file for ruby 1.9.3-p125@rubaship

Signed-off-by: João Soares <jsoaresgeral@gmail.com>
Improves Board access with #[] and .row_to_index

Adds Board#[] method and .row_to_index helper method to provide easier
api access to the contents of the board.
Board.row_to_index allow to translate row identifiers based on a symbol
or a String to its equivalent index value.

Signed-off-by: João Soares <jsoaresgeral@gmail.com>
Adds feature place ships on the board and steps

Adds Place ships on the board feature along with step definitions

Signed-off-by: João Soares <jsoaresgeral@gmail.com>
Add Ship #position and #placed? initial behaviour

Adds #position and #placed attributes providing support for checking
if a ship is already placed on the board and, if true, where.
All ships are created with position = nil and placed = false.
Adds a helper method #placed? that return the #placed attribute status.
Still lacks the implementation of Player#place to specify further
behaviour.

Signed-off-by: João Soares <jsoaresgeral@gmail.com>
Improves Board.row_to_index to support Ranges

Adds support to symbol, string and fixnum ranges to use with the #[]
operator.
When passed a symbol or string Range it translates the Range to a
fixnum Range, when passed a fixnum Range it returns the argument
passed unchanged.

Signed-off-by: João Soares <jsoaresgeral@gmail.com>
Refactors Board.row_to_index to use case instead

Refactor Board.row_to_index to use a case statement instead of the
previous if-elsif sequence.
Minor adjustments in specifications for Board#[], essencially to
ensure expected functionality of Board.row_to_index and adds some
examples.

Signed-off-by: João Soares <jsoaresgeral@gmail.com>
Refactors Board#== to use a case statement

Provides better reading code after the refactoring of the method.

Signed-off-by: João Soares <jsoaresgeral@gmail.com>
Changes Board.parse_location to translate cols

Changes the implementation of the helper method Board.parse_location
to translate human common sense location columns to array indexed
columns

Signed-off-by: João Soares <jsoaresgeral@gmail.com>
Adds support code for adding ships to the board

Implements the internal method Board#add! to add ships to the board
which uses the helper methods Ship#to_a and Ship#to_s.

Signed-off-by: João Soares <jsoaresgeral@gmail.com>
Implements Player#place method

Finishes the implementation of the feature "place ships on the board"
Adds the Player#place method which make heavy use of Board#add! and
Ship#position=
Improves the "place ships on the board" feature to cover more cases.

Signed-off-by: João Soares <jsoaresgeral@gmail.com>
Switches in ship order destroyer by submarine

Changes fixed ship list order, switching destroyer by submarine,
changing also features and specs to comply with the specification
change.
Also refactors Ship methods .ships and .index

Signed-off-by: João Soares <jsoaresgeral@gmail.com>
Includes invalid arguments to Ship.create specs

Adds examples of invalid arguments to Ship.create specs.

Signed-off-by: João Soares <jsoaresgeral@gmail.com>
Rename method Board.parse_location to parse_pos

Alters all references to location and replaces it by position which
is supposed to better fit the game idiom.

Signed-off-by: João Soares <jsoaresgeral@gmail.com>
Adds Board::ROWS as a reference of the valid rows

Adds Board::Rows constant and changed algorithms to use it where
necessary to allow more readable code and better express its goals

Signed-off-by: João Soares <jsoaresgeral@gmail.com>
Implements Sector as a Board cell

Adds Sector which may contain a ship or nil for each Board cell, this
is the first stage of the two step implementation of Board sectors
that will support accessing shot information for each sector.

Signed-off-by: João Soares <jsoaresgeral@gmail.com>
Major reimplementation of Board position parsing

Changes the way positions are parsed and passed to methods, the
previous hash { row: :G, col: 3, ori: :H } generated by the method
Board.parse_pos is replaced by an array representation of the same
position [ :G, 3, :H], which can assume several shapes and forms.

Rows and columns can be Symbols, Strings, Ranges(also Symbols,
Strings and Fixnums) and Fixnums while orientation can be a Symbol,
a String with varible lenght and true(horizontal) or false(vertical).

Board.col_to_index now accepts a second argument(true of false) which
changes the translation of column indexes to array format or board
format.

Signed-off-by: João Soares <jsoaresgeral@gmail.com>
Renames some Board class methods to shorter names

Renames the Board class methods:
 * Board.row_to_index  => Board.row_to_idx
 * Board.col_to_index  => Board.col_to_idx
 * Board.pos_to_simple => Board.format_pos

The goal is to have a shorter api syntax, clearer and easier to read.
Also updates all references to the renamed methods including on steps
from features.

Signed-off-by: João Soares <jsoaresgeral@gmail.com>
Refines Board.ori_to_sym to integrate public api

Improves Board.ori_to_sym, adding a custom ArgumentError exception and
refining the regexp used to parse the string format.
Board.ori_to_sym now raises an exception if the string or symbol passed
are invalid.

Signed-off-by: João Soares <jsoaresgeral@gmail.com>
Refactors Board class to improve code readability

Signed-off-by: João Soares <jsoaresgeral@gmail.com>
Adds InvalidRowArgument and InvalidColumnArgument

Refactors Board.row_to_idx and Board.col_to_idx to use the new
Exceptions InvalidRowArgument and InvalidColumnArgument created.
Alters Board#add! to rescue the exceptions raise by the above
helper methods and return false in case of an unsuccessful add.

Signed-off-by: João Soares <jsoaresgeral@gmail.com>