Class: Pacman::Arcade::Direction

Inherits:
Data
  • Object
show all
Defined in:
lib/pacman/arcade/direction.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dxObject (readonly)

Returns the value of attribute dx

Returns:

  • (Object)

    the current value of dx



5
6
7
# File 'lib/pacman/arcade/direction.rb', line 5

def dx
  @dx
end

#dyObject (readonly)

Returns the value of attribute dy

Returns:

  • (Object)

    the current value of dy



5
6
7
# File 'lib/pacman/arcade/direction.rb', line 5

def dy
  @dy
end

Class Method Details

.allObject



14
# File 'lib/pacman/arcade/direction.rb', line 14

def self.all = [up, down, left, right]

.downObject



8
# File 'lib/pacman/arcade/direction.rb', line 8

def self.down = @down ||= new(dy: 1, dx: 0)

.leftObject



10
# File 'lib/pacman/arcade/direction.rb', line 10

def self.left = @left ||= new(dy: 0, dx: -1)

.rightObject



12
# File 'lib/pacman/arcade/direction.rb', line 12

def self.right = @right ||= new(dy: 0, dx: 1)

.upObject



6
# File 'lib/pacman/arcade/direction.rb', line 6

def self.up = @up ||= new(dy: -1, dx: 0)

Instance Method Details

#oppositeObject



16
# File 'lib/pacman/arcade/direction.rb', line 16

def opposite = Direction.new(dy: -dy, dx: -dx)