twisty_puzzles 0.0.20 → 0.0.21

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: b520c95ebe0051fb847be3781d6f82a6b2f41f00e006e3935157d8c6c3843726
4
- data.tar.gz: 8cfb1439b07cf4983d17198952d56ae4b903afa994c67c549ea210063bc42eb9
3
+ metadata.gz: be82a2641267d469bc68c47799c03783467777a5b8279e5d9dcf7341de653ed6
4
+ data.tar.gz: '048163ad5b5711cbfa50e6a5a63157938f5fe77cf4185e069d0093d29faf2159'
5
5
  SHA512:
6
- metadata.gz: b841bc0e3f1de064c2bee48eaf041528abeec5b3751486b380933ead4633ea78430445793351bf3a80eff1da9d2b535ecea6dd63ace544c18f0a456b5fd348fe
7
- data.tar.gz: 8732d36c49fc52b9292401b82b1b795f6f00994bb0ab80d2cbb029555af383fd20769cb083bb7d2af3348d7fda7811d76b693764f30699a79d239bde2cf93151
6
+ metadata.gz: 3fb21ebf301992496ae43c9c7139bd518db0d7973020b78a8151fce1799e406eae182e0585d862493a22c6ae6d6168d17e9be81cda858fbca261f50651a803ea
7
+ data.tar.gz: 526eba7127c4c83a9f3c1b1a8c6addb270a678e37311bada9418cfd74455590753f2ae756a9b0454008d9965cac563dd30fd6d1929e1935969fd0c3e643a5ec4
@@ -672,4 +672,8 @@ module TwistyPuzzles
672
672
  [1 + incarnation_index, cube_size / 2]
673
673
  end
674
674
  end
675
+
676
+ # TODO: Add obliques
677
+
678
+ PART_TYPES = [Corner, Edge, XCenter, TCenter, Face, Edge, Midge, Wing].freeze
675
679
  end
@@ -13,6 +13,8 @@ module TwistyPuzzles
13
13
  include Utils::ArrayHelper
14
14
 
15
15
  def initialize(parts)
16
+ raise ArgumentError if parts.empty?
17
+
16
18
  check_types(parts, Part)
17
19
  check_type_consistency(parts)
18
20
 
@@ -31,6 +33,29 @@ module TwistyPuzzles
31
33
  @hash ||= ([self.class] + @parts).hash
32
34
  end
33
35
 
36
+ def part_type
37
+ @parts.first.class
38
+ end
39
+
40
+ def to_s
41
+ @parts.join(' ')
42
+ end
43
+
44
+ def to_raw_data
45
+ "#{part_type}(#{self})"
46
+ end
47
+
48
+ def length
49
+ @parts.length
50
+ end
51
+
52
+ def self.from_raw_data(data)
53
+ raw_part_type, raw_parts = data.match(/(.*)\((.*)\)/).captures
54
+ part_type = PART_TYPES.find { |p| p.name == raw_part_type }
55
+ parts = raw_parts.split.map { |r| part_type.parse(r) }
56
+ new(parts)
57
+ end
58
+
34
59
  def check_type_consistency(parts)
35
60
  return unless parts.any? { |p| p.class != parts.first.class }
36
61
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TwistyPuzzles
4
- VERSION = '0.0.20'
4
+ VERSION = '0.0.21'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twisty_puzzles
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.20
4
+ version: 0.0.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bernhard F. Brodowsky