Class: Move

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(word, position, direction) ⇒ Move

Returns a new instance of Move.



4
5
6
7
8
# File 'lib/move.rb', line 4

def initialize(word, position, direction)
  @word = word
  @position = position
  @direction = direction
end

Instance Attribute Details

#directionObject (readonly)

Returns the value of attribute direction.



2
3
4
# File 'lib/move.rb', line 2

def direction
  @direction
end

#positionObject (readonly)

Returns the value of attribute position.



2
3
4
# File 'lib/move.rb', line 2

def position
  @position
end

#wordObject (readonly)

Returns the value of attribute word.



2
3
4
# File 'lib/move.rb', line 2

def word
  @word
end

Instance Method Details

#==(other) ⇒ Object



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

def ==(other)
  [word, position, direction] == [other.word, other.position, other.direction]
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


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

def eql?(other)
  [word, position, direction].eql?[other.word, other.position, other.direction]
end

#hashObject



18
19
20
# File 'lib/move.rb', line 18

def hash
  [word, position, direction].hash
end