Class: TwistyPuzzles::StickerCycle

Inherits:
Object
  • Object
show all
Includes:
ReversibleApplyable
Defined in:
lib/twisty_puzzles/sticker_cycle.rb

Overview

A sticker cycle that can be applied to a cube state. TODO: Deprecate

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ReversibleApplyable

#apply_temporarily_to, #apply_to_dupped

Constructor Details

#initialize(native) ⇒ StickerCycle

Returns a new instance of StickerCycle.

Raises:

  • (TypeError)


21
22
23
24
25
# File 'lib/twisty_puzzles/sticker_cycle.rb', line 21

def initialize(native)
  raise TypeError unless native.is_a?(Native::StickerCycle)

  @native = native
end

Instance Attribute Details

#nativeObject (readonly)

Returns the value of attribute native.



27
28
29
# File 'lib/twisty_puzzles/sticker_cycle.rb', line 27

def native
  @native
end

Class Method Details

.from_coordinates(cube_size, coordinates) ⇒ Object

Raises:

  • (TypeError)


14
15
16
17
18
19
# File 'lib/twisty_puzzles/sticker_cycle.rb', line 14

def self.from_coordinates(cube_size, coordinates)
  CubeState.check_cube_size(cube_size)
  raise TypeError unless coordinates.all?(Coordinate)

  new(Native::StickerCycle.new(cube_size, coordinates.map(&:native)))
end

Instance Method Details

#apply_to(cube_state) ⇒ Object

Raises:

  • (TypeError)


47
48
49
50
51
# File 'lib/twisty_puzzles/sticker_cycle.rb', line 47

def apply_to(cube_state)
  raise TypeError unless cube_state.is_a?(CubeState)

  @native.apply_to(cube_state.native)
end

#cube_sizeObject



39
40
41
# File 'lib/twisty_puzzles/sticker_cycle.rb', line 39

def cube_size
  @native.cube_size
end

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

Returns:

  • (Boolean)


29
30
31
# File 'lib/twisty_puzzles/sticker_cycle.rb', line 29

def eql?(other)
  self.class.equal?(other.class) && @native == other.native
end

#hashObject



35
36
37
# File 'lib/twisty_puzzles/sticker_cycle.rb', line 35

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

#inverseObject



53
54
55
# File 'lib/twisty_puzzles/sticker_cycle.rb', line 53

def inverse
  StickerCycle.new(@native.inverse)
end

#lengthObject



43
44
45
# File 'lib/twisty_puzzles/sticker_cycle.rb', line 43

def length
  @native.length
end