class RGrid::Grid

The grid data structure class.

@api public

Public Class Methods

new(x: 0, xn: 0, y: 0, yn: 0) click to toggle source

@param x [Fixnum] @param xn [Fixnum] @param y [Fixnum] @param yn [Fixnum] @return [RGrid::Grid]

# File lib/rgrid/grid.rb, line 16
def initialize(x: 0, xn: 0, y: 0, yn: 0)
  @x  = x
  @xn = xn
  @y  = y
  @yn = yn

  validate!
end

Public Instance Methods

attributes() click to toggle source

@return [Hash<Symbol => Fixnum>]

# File lib/rgrid/grid.rb, line 26
def attributes
  {
    x:  @x,
    xn: @xn,
    y:  @y,
    yn: @yn,
  }
end

Private Instance Methods

validate!() click to toggle source

@raise [RGrid::InvalidGrid] When the atttributes are not sane. @return [RGrid::Grid]

# File lib/rgrid/grid.rb, line 39
def validate!
  raise RGrid::InvalidGrid unless RGrid::Validator.valid?(attributes)

  self
end