Class: TwistyPuzzles::Puzzle

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

Overview

Represents one type of puzzle.

Constant Summary collapse

NXN_CUBE =
Puzzle.new('nxn cube')
SKEWB =
Puzzle.new('skewb')

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Puzzle

Returns a new instance of Puzzle.



6
7
8
# File 'lib/twisty_puzzles/puzzle.rb', line 6

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



13
14
15
# File 'lib/twisty_puzzles/puzzle.rb', line 13

def name
  @name
end

Instance Method Details

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


15
16
17
# File 'lib/twisty_puzzles/puzzle.rb', line 15

def eql?(other)
  self.class == other.class && name == other.name
end

#hashObject



19
20
21
# File 'lib/twisty_puzzles/puzzle.rb', line 19

def hash
  @hash ||= [self.class, @name].hash
end