Class: Coordinates

Inherits:
Vector2d
  • Object
show all
Defined in:
lib/fantasy/coordinates.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#x=(value) ⇒ Object (writeonly)

Sets the attribute x

Parameters:

  • value

    the value to set the attribute x to.



6
7
8
# File 'lib/fantasy/coordinates.rb', line 6

def x=(value)
  @x = value
end

#y=(value) ⇒ Object (writeonly)

Sets the attribute y

Parameters:

  • value

    the value to set the attribute y to.



6
7
8
# File 'lib/fantasy/coordinates.rb', line 6

def y=(value)
  @y = value
end

Class Method Details

.downObject



16
17
18
# File 'lib/fantasy/coordinates.rb', line 16

def self.down
  Coordinates.new(0, 1)
end

.leftObject



20
21
22
# File 'lib/fantasy/coordinates.rb', line 20

def self.left
  Coordinates.new(-1, 0)
end

.rightObject



24
25
26
# File 'lib/fantasy/coordinates.rb', line 24

def self.right
  Coordinates.new(1, 0)
end

.upObject



12
13
14
# File 'lib/fantasy/coordinates.rb', line 12

def self.up
  Coordinates.new(0, -1)
end

.zeroObject



8
9
10
# File 'lib/fantasy/coordinates.rb', line 8

def self.zero
  Coordinates.new(0, 0)
end

Instance Method Details

#cloneObject



28
29
30
# File 'lib/fantasy/coordinates.rb', line 28

def clone
  Coordinates.new(@x, @y)
end

#zero?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/fantasy/coordinates.rb', line 32

def zero?
  @x.zero? && @y.zero?
end