Class: Move

Inherits:
Object
  • Object
show all
Defined in:
lib/software_challenge_client/move.rb

Overview

A move, that can be performed in twixt

Author:

  • Ralf-Tobias Diekert

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x, y) ⇒ Move

Initializer

Parameters:

  • x (Integer)

    x-coordinate

  • y (Integer)

    y-coordinate



20
21
22
23
24
# File 'lib/software_challenge_client/move.rb', line 20

def initialize(x, y)
  @x = x
  @y = y
  @hints = Array.new
end

Instance Attribute Details

#hintsArray<DebugHint> (readonly)

Returns the move’s hints.

Returns:



14
15
16
# File 'lib/software_challenge_client/move.rb', line 14

def hints
  @hints
end

#xInteger (readonly)

Returns x-coordinate.

Returns:

  • (Integer)

    x-coordinate



8
9
10
# File 'lib/software_challenge_client/move.rb', line 8

def x
  @x
end

#yInteger (readonly)

Returns y-coordinate.

Returns:

  • (Integer)

    y-coordinate



11
12
13
# File 'lib/software_challenge_client/move.rb', line 11

def y
  @y
end

Instance Method Details

#==(another_move) ⇒ Object



50
51
52
# File 'lib/software_challenge_client/move.rb', line 50

def ==(another_move)
  return self.x == another_move.x && self.y == another_move.y
end

#addHint(string) ⇒ Object

adds a hint to the move



36
37
38
# File 'lib/software_challenge_client/move.rb', line 36

def addHint(hint)
  @hints.push(hint);
end

#to_sObject



54
55
56
# File 'lib/software_challenge_client/move.rb', line 54

def to_s
  return "Move:(#{self.x},#{self.y})"
end