class BoardGameGrid::Point

Point

A point with an x and y co-ordinates

Attributes

x[R]

@return [Fixnum] the x co-ordinate.

y[R]

@return [Fixnum] the y co-ordinate.

Public Class Methods

new(x, y) click to toggle source

New objects can be instantiated with

@param [Fixnum] x

the x co-ordinate.

@param [Fixnum] y

the y co-ordinate.

Example:

# Instantiates a new Point
BoardGameGrid::Point.new({
  x: 1,
  y: 1
})
# File lib/board_game_grid/point.rb, line 22
def initialize(x, y)
  @x, @y = x, y
end

Public Instance Methods

+(other) click to toggle source

Add a point to another point by adding their co-ordinates and returning a new point.

@param [Point] other

the other point to add.

@return [Point]

# File lib/board_game_grid/point.rb, line 38
def +(other)
  self.class.new(self.x + other.x, self.y + other.y)
end
==(other) click to toggle source

Check if popints are equal by seeing if their co-ordinates are equal.

@param [Point] other

the other point to compare to.

@return [TrueClass, FalseClass]

# File lib/board_game_grid/point.rb, line 48
def ==(other)
  self.x == other.x && self.y == other.y
end