Module: Sashite::Cell
- Defined in:
- lib/sashite/cell.rb,
lib/sashite/cell/parser.rb,
lib/sashite/cell/constants.rb,
lib/sashite/cell/formatter.rb,
lib/sashite/cell/coordinate.rb,
lib/sashite/cell/errors/argument.rb,
lib/sashite/cell/errors/argument/messages.rb
Overview
CELL (Coordinate Encoding for Layered Locations) implementation.
Provides parsing, formatting, and validation of CELL coordinates for multi-dimensional game boards (up to 3 dimensions).
Defined Under Namespace
Modules: Constants, Errors, Formatter, Parser Classes: Coordinate
Class Method Summary collapse
-
.format(*indices) ⇒ String
Formats indices into a CELL string.
-
.parse(string) ⇒ Coordinate
Parses a CELL string into a Coordinate.
-
.valid?(string) ⇒ Boolean
Reports whether string is a valid CELL coordinate.
-
.validate(string) ⇒ nil
Validates a CELL string.
Class Method Details
.format(*indices) ⇒ String
Formats indices into a CELL string.
51 52 53 |
# File 'lib/sashite/cell.rb', line 51 def self.format(*indices) Coordinate.new(*indices).to_s end |
.parse(string) ⇒ Coordinate
Parses a CELL string into a Coordinate.
38 39 40 |
# File 'lib/sashite/cell.rb', line 38 def self.parse(string) Coordinate.new(*Parser.parse_to_indices(string)) end |
.valid?(string) ⇒ Boolean
Reports whether string is a valid CELL coordinate.
77 78 79 80 81 82 |
# File 'lib/sashite/cell.rb', line 77 def self.valid?(string) validate(string) true rescue Errors::Argument false end |
.validate(string) ⇒ nil
Validates a CELL string.
64 65 66 67 |
# File 'lib/sashite/cell.rb', line 64 def self.validate(string) Parser.parse_to_indices(string) nil end |