Class: RubiksCube::Solution
- Inherits:
-
Object
- Object
- RubiksCube::Solution
- Defined in:
- lib/rubiks_cube/solution.rb
Overview
Abstract interface for a RubiksCube solution
Must implement:
solution: array or string of moves necessary to solve the cube
pretty: human readable string of solution
Direct Known Subclasses
Instance Attribute Summary collapse
-
#cube ⇒ Object
readonly
Returns the value of attribute cube.
Instance Method Summary collapse
-
#initialize(cube) ⇒ Solution
constructor
A new instance of Solution.
- #length ⇒ Object
-
#pretty ⇒ Object
Human readable string of solution.
-
#solution ⇒ Object
Array or String of moves necessary to solve the cube.
- #solved? ⇒ Boolean
- #state ⇒ Object
Constructor Details
Instance Attribute Details
#cube ⇒ Object (readonly)
Returns the value of attribute cube.
8 9 10 |
# File 'lib/rubiks_cube/solution.rb', line 8 def cube @cube end |
Instance Method Details
#length ⇒ Object
32 33 34 |
# File 'lib/rubiks_cube/solution.rb', line 32 def length Array(solution).flatten.join(' ').split.count end |
#pretty ⇒ Object
Human readable string of solution
16 17 18 |
# File 'lib/rubiks_cube/solution.rb', line 16 def pretty raise "#pretty unimplemented in #{self.class.name}" end |
#solution ⇒ Object
Array or String of moves necessary to solve the cube
11 12 13 |
# File 'lib/rubiks_cube/solution.rb', line 11 def solution raise "#solution unimplemented in #{self.class.name}" end |
#solved? ⇒ Boolean
28 29 30 |
# File 'lib/rubiks_cube/solution.rb', line 28 def solved? cube.solved? end |
#state ⇒ Object
24 25 26 |
# File 'lib/rubiks_cube/solution.rb', line 24 def state cube.state end |