Class: Pacman::Arcade::Direction
- Inherits:
-
Data
- Object
- Data
- Pacman::Arcade::Direction
- Defined in:
- lib/pacman/arcade/direction.rb
Instance Attribute Summary collapse
-
#dx ⇒ Object
readonly
Returns the value of attribute dx.
-
#dy ⇒ Object
readonly
Returns the value of attribute dy.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#dx ⇒ Object (readonly)
Returns the value of attribute dx
5 6 7 |
# File 'lib/pacman/arcade/direction.rb', line 5 def dx @dx end |
#dy ⇒ Object (readonly)
Returns the value of attribute dy
5 6 7 |
# File 'lib/pacman/arcade/direction.rb', line 5 def dy @dy end |
Class Method Details
.all ⇒ Object
14 |
# File 'lib/pacman/arcade/direction.rb', line 14 def self.all = [up, down, left, right] |
.down ⇒ Object
8 |
# File 'lib/pacman/arcade/direction.rb', line 8 def self.down = @down ||= new(dy: 1, dx: 0) |
.left ⇒ Object
10 |
# File 'lib/pacman/arcade/direction.rb', line 10 def self.left = @left ||= new(dy: 0, dx: -1) |
.right ⇒ Object
12 |
# File 'lib/pacman/arcade/direction.rb', line 12 def self.right = @right ||= new(dy: 0, dx: 1) |
.up ⇒ Object
6 |
# File 'lib/pacman/arcade/direction.rb', line 6 def self.up = @up ||= new(dy: -1, dx: 0) |
Instance Method Details
#opposite ⇒ Object
16 |
# File 'lib/pacman/arcade/direction.rb', line 16 def opposite = Direction.new(dy: -dy, dx: -dx) |