Class: TwistyPuzzles::FakeCommutator
- Inherits:
-
Commutator
- Object
- Commutator
- TwistyPuzzles::FakeCommutator
- Defined in:
- lib/twisty_puzzles/commutator.rb
Overview
Algorithm that is used like a commutator but actually isn’t one.
Instance Attribute Summary collapse
-
#algorithm ⇒ Object
readonly
Returns the value of attribute algorithm.
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean (also: #==)
- #hash ⇒ Object
-
#initialize(algorithm) ⇒ FakeCommutator
constructor
A new instance of FakeCommutator.
- #inverse ⇒ Object
- #to_s ⇒ Object
Methods inherited from Commutator
Constructor Details
#initialize(algorithm) ⇒ FakeCommutator
Returns a new instance of FakeCommutator.
21 22 23 24 25 26 |
# File 'lib/twisty_puzzles/commutator.rb', line 21 def initialize(algorithm) raise TypeError unless algorithm.is_a?(Algorithm) super() @algorithm = algorithm end |
Instance Attribute Details
#algorithm ⇒ Object (readonly)
Returns the value of attribute algorithm.
28 29 30 |
# File 'lib/twisty_puzzles/commutator.rb', line 28 def algorithm @algorithm end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
30 31 32 |
# File 'lib/twisty_puzzles/commutator.rb', line 30 def eql?(other) self.class.equal?(other.class) && @algorithm == other.algorithm end |
#hash ⇒ Object
36 37 38 |
# File 'lib/twisty_puzzles/commutator.rb', line 36 def hash @hash ||= [self.class, @algorithm].hash end |
#inverse ⇒ Object
40 41 42 |
# File 'lib/twisty_puzzles/commutator.rb', line 40 def inverse FakeCommutator.new(@algorithm.inverse) end |
#to_s ⇒ Object
44 45 46 |
# File 'lib/twisty_puzzles/commutator.rb', line 44 def to_s @algorithm.to_s end |