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



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

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

Instance Attribute Details

#hintsArray<DebugHint> (readonly)

Returns the move’s hints.

Returns:



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

def hints
  @hints
end

#xInteger (readonly)

Returns x-coordinate.

Returns:

  • (Integer)

    x-coordinate



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

def x
  @x
end

#yInteger (readonly)

Returns y-coordinate.

Returns:

  • (Integer)

    y-coordinate



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

def y
  @y
end

Instance Method Details

#==(another_move) ⇒ Object



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

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

#addHint(string) ⇒ Object

adds a hint to the move



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

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

#to_sObject



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

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