Class: Move
- Inherits:
-
Object
- Object
- Move
- Defined in:
- lib/move.rb
Instance Attribute Summary collapse
-
#direction ⇒ Object
readonly
Returns the value of attribute direction.
-
#position ⇒ Object
readonly
Returns the value of attribute position.
-
#word ⇒ Object
readonly
Returns the value of attribute word.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(word, position, direction) ⇒ Move
constructor
A new instance of Move.
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
#direction ⇒ Object (readonly)
Returns the value of attribute direction.
2 3 4 |
# File 'lib/move.rb', line 2 def direction @direction end |
#position ⇒ Object (readonly)
Returns the value of attribute position.
2 3 4 |
# File 'lib/move.rb', line 2 def position @position end |
#word ⇒ Object (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
14 15 16 |
# File 'lib/move.rb', line 14 def eql?(other) [word, position, direction].eql?[other.word, other.position, other.direction] end |
#hash ⇒ Object
18 19 20 |
# File 'lib/move.rb', line 18 def hash [word, position, direction].hash end |