twisty_puzzles 0.0.19 → 0.0.20
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b520c95ebe0051fb847be3781d6f82a6b2f41f00e006e3935157d8c6c3843726
|
4
|
+
data.tar.gz: 8cfb1439b07cf4983d17198952d56ae4b903afa994c67c549ea210063bc42eb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b841bc0e3f1de064c2bee48eaf041528abeec5b3751486b380933ead4633ea78430445793351bf3a80eff1da9d2b535ecea6dd63ace544c18f0a456b5fd348fe
|
7
|
+
data.tar.gz: 8732d36c49fc52b9292401b82b1b795f6f00994bb0ab80d2cbb029555af383fd20769cb083bb7d2af3348d7fda7811d76b693764f30699a79d239bde2cf93151
|
@@ -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
|
9
|
+
class StickerCycleFactory
|
9
10
|
include Utils::ArrayHelper
|
10
11
|
|
11
12
|
def initialize(cube_size, incarnation_index)
|
data/lib/twisty_puzzles.rb
CHANGED
@@ -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/
|
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.
|
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-
|
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/
|
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
|