class Bayonet::Cell

Constants

ROW_MATCHER

Attributes

column[R]
row[R]

Public Class Methods

new(row, column) click to toggle source
# File lib/bayonet/cell.rb, line 6
def initialize(row, column)
  @row    = row
  @column = column
end

Public Instance Methods

label() click to toggle source
# File lib/bayonet/cell.rb, line 11
def label
  cell_label = "#{row}#{column}"
  if valid?
    cell_label
  else
    raise "Invalid cell: #{cell_label}."
  end
end
valid?() click to toggle source
# File lib/bayonet/cell.rb, line 20
def valid?
  row_valid? && column_valid?
end

Private Instance Methods

column_valid?() click to toggle source
# File lib/bayonet/cell.rb, line 32
def column_valid?
  column.is_a?(Integer) && column >= 1
end
row_valid?() click to toggle source
# File lib/bayonet/cell.rb, line 28
def row_valid?
  (row =~ ROW_MATCHER) != nil
end