twisty_puzzles 0.0.19 → 0.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 64f6766819367eee6807388d640a4302c3268bcf276a2b52fb4ca94ddbb0ebe2
4
- data.tar.gz: 0d60796788d180feb10ad42fa74a6b7535092d5d4040a64375f959ac9a2023da
3
+ metadata.gz: b520c95ebe0051fb847be3781d6f82a6b2f41f00e006e3935157d8c6c3843726
4
+ data.tar.gz: 8cfb1439b07cf4983d17198952d56ae4b903afa994c67c549ea210063bc42eb9
5
5
  SHA512:
6
- metadata.gz: 36cb5bdc5b75cfcb7d0a832cbff120662426ab8dd1fd1120762c3231973f27b706059f6772193ca76403859a3768d847f9ee34fb4012c52deb19226862b8b38c
7
- data.tar.gz: 8e6a49720c6219484741a6d5d3248917c02025def3c0eacac34b0de07529b7fe42802fd5473fb782a19ca34f7bbc7319b8ef4ee705bffd135240f9d12f6eb77c
6
+ metadata.gz: b841bc0e3f1de064c2bee48eaf041528abeec5b3751486b380933ead4633ea78430445793351bf3a80eff1da9d2b535ecea6dd63ace544c18f0a456b5fd348fe
7
+ data.tar.gz: 8732d36c49fc52b9292401b82b1b795f6f00994bb0ab80d2cbb029555af383fd20769cb083bb7d2af3348d7fda7811d76b693764f30699a79d239bde2cf93151
@@ -28,7 +28,6 @@ module TwistyPuzzles
28
28
  @colors_to_face_symbols = face_symbols_to_colors.invert
29
29
  end
30
30
 
31
-
32
31
  def eql?(other)
33
32
  self.class.equal?(other.class) && colors == other.colors
34
33
  end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'twisty_puzzles/utils/array_helper'
4
+ require 'twisty_puzzles/sticker_cycle_factory'
5
+ require 'twisty_puzzles/cube'
6
+
7
+ module TwistyPuzzles
8
+ # A cycle of parts of the cube, e.g. a corner 3 cycle.
9
+ # Note that this is abstract and contains no information on the cube size.
10
+ # E.g. for wings on a 7x7, it's not clear whether inner or outer wings are used.
11
+ # Check StickerCycleFactory for making it concrete and applyable.
12
+ class PartCycle
13
+ include Utils::ArrayHelper
14
+
15
+ def initialize(parts)
16
+ check_types(parts, Part)
17
+ check_type_consistency(parts)
18
+
19
+ @parts = parts
20
+ end
21
+
22
+ attr_reader :parts
23
+
24
+ def eql?(other)
25
+ self.class.equal?(other.class) && @parts == other.parts
26
+ end
27
+
28
+ alias == eql?
29
+
30
+ def hash
31
+ @hash ||= ([self.class] + @parts).hash
32
+ end
33
+
34
+ def check_type_consistency(parts)
35
+ return unless parts.any? { |p| p.class != parts.first.class }
36
+
37
+ raise TypeError, "Cycles of heterogenous piece types #{parts.inspect} are not supported."
38
+ end
39
+ end
40
+ end
@@ -2,10 +2,11 @@
2
2
 
3
3
  require 'twisty_puzzles/sticker_cycle'
4
4
  require 'twisty_puzzles/utils/array_helper'
5
+ require 'twisty_puzzles/cube'
5
6
 
6
7
  module TwistyPuzzles
7
8
  # Factory for sticker cycles given part cycles.
8
- class PartCycleFactory
9
+ class StickerCycleFactory
9
10
  include Utils::ArrayHelper
10
11
 
11
12
  def initialize(cube_size, incarnation_index)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TwistyPuzzles
4
- VERSION = '0.0.19'
4
+ VERSION = '0.0.20'
5
5
  end
@@ -24,7 +24,7 @@ require 'twisty_puzzles/letter_scheme'
24
24
  require 'twisty_puzzles/move_type_creator'
25
25
  require 'twisty_puzzles/native'
26
26
  require 'twisty_puzzles/parser'
27
- require 'twisty_puzzles/part_cycle_factory'
27
+ require 'twisty_puzzles/part_cycle'
28
28
  require 'twisty_puzzles/puzzle'
29
29
  require 'twisty_puzzles/reversible_applyable'
30
30
  require 'twisty_puzzles/rotation'
@@ -34,6 +34,7 @@ require 'twisty_puzzles/skewb_move_parser'
34
34
  require 'twisty_puzzles/skewb_notation'
35
35
  require 'twisty_puzzles/skewb_state'
36
36
  require 'twisty_puzzles/sticker_cycle'
37
+ require 'twisty_puzzles/sticker_cycle_factory'
37
38
  require 'twisty_puzzles/twisty_puzzles_error'
38
39
  require 'twisty_puzzles/version'
39
40
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twisty_puzzles
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.19
4
+ version: 0.0.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bernhard F. Brodowsky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-08 00:00:00.000000000 Z
11
+ date: 2021-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -224,7 +224,7 @@ files:
224
224
  - lib/twisty_puzzles/letter_scheme.rb
225
225
  - lib/twisty_puzzles/move_type_creator.rb
226
226
  - lib/twisty_puzzles/parser.rb
227
- - lib/twisty_puzzles/part_cycle_factory.rb
227
+ - lib/twisty_puzzles/part_cycle.rb
228
228
  - lib/twisty_puzzles/puzzle.rb
229
229
  - lib/twisty_puzzles/reversible_applyable.rb
230
230
  - lib/twisty_puzzles/rotation.rb
@@ -234,6 +234,7 @@ files:
234
234
  - lib/twisty_puzzles/skewb_notation.rb
235
235
  - lib/twisty_puzzles/skewb_state.rb
236
236
  - lib/twisty_puzzles/sticker_cycle.rb
237
+ - lib/twisty_puzzles/sticker_cycle_factory.rb
237
238
  - lib/twisty_puzzles/twisty_puzzles_error.rb
238
239
  - lib/twisty_puzzles/utils.rb
239
240
  - lib/twisty_puzzles/utils/array_helper.rb