fiber_units 0.2.0 → 0.3.0

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: 82ac302d86901a24e9b0d6cd38cc5185978360173454fa13cdbacaa4c295e2de
4
- data.tar.gz: 60d959472750dab825784939543b4e5ab1838b21173e069ca89ba1fe0290c82e
3
+ metadata.gz: b852a73832747576078a185f9e3fab2a926fd9836d4df9b6a6ce05e2f5718436
4
+ data.tar.gz: 37e5f5208b1c12a13d9c1f01a30d87f7508520df120c4c99bc9fd1810a73bbb1
5
5
  SHA512:
6
- metadata.gz: 78a95907d6a3b37167ac797f65e410a2c7f676fbb595f41b50b31089077bb21b99c4a113e0a6736637eb206d776f4190eb369838af9de2ef261f069004f71484
7
- data.tar.gz: 77066078c243b350dd7bd144fa9452263105bb4bff9d0bc876e0a6f4ab304bea09e2bb6bdf5e8efda46de7985edf3738e9a104a3f8190597509ea1fb6417b80d
6
+ metadata.gz: 0b7b1a97a8d92bb353e9296592ca712f176e737119ba064eb2122a1f7fc8181cc02db21860e86e818ab999412ce23ec753d3a6070293e4242b7507a6d965ee3f
7
+ data.tar.gz: 532b9eb308506abaef91e538bb6bfc247a82355130141e10cdb2827925d1034111156648947832feda0406c03d667713f0c6f68f0aecdb5e0b50e4263324147e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.3.0] - 2026-03-14
4
+
5
+ ### Added
6
+ - Shared `Count` base class for `RowCount` and `StitchCount`
7
+ - Equality and comparison behavior for `StitchCount` and `RowCount`
8
+ - Coverage for shared count behavior through `RowCount` and `StitchCount` specs
9
+
3
10
  ## [0.2.0] - 2026-03-09
4
11
 
5
12
  ### Added
@@ -0,0 +1,48 @@
1
+ module FiberUnits
2
+ class Count
3
+ include Comparable
4
+
5
+ attr_reader :value
6
+
7
+ def initialize(value, _unit = nil)
8
+ @value = value
9
+ freeze
10
+ end
11
+
12
+ def +(other)
13
+ ensure_same_class!(other)
14
+ self.class.new(value + other.value)
15
+ end
16
+
17
+ def -(other)
18
+ ensure_same_class!(other)
19
+ self.class.new(value - other.value)
20
+ end
21
+
22
+ def *(other)
23
+ self.class.new(value * other)
24
+ end
25
+
26
+ def to_i
27
+ value
28
+ end
29
+
30
+ def <=>(other)
31
+ return nil unless other.instance_of?(self.class)
32
+ value <=> other.value
33
+ end
34
+
35
+ def ==(other)
36
+ other.class == self.class && other.value == value
37
+ end
38
+
39
+ private
40
+
41
+ def ensure_same_class!(other)
42
+ unless other.instance_of?(self.class)
43
+ raise FiberUnits::DimensionError,
44
+ "Cannot combine #{self.class} with #{other.class}"
45
+ end
46
+ end
47
+ end
48
+ end
@@ -1,13 +1,4 @@
1
1
  module FiberUnits
2
- class RowCount
3
- attr_reader :value
4
-
5
- def initialize(value, _unit = nil)
6
- @value = value
7
- end
8
-
9
- def +(other)
10
- RowCount.new(value + other.value)
11
- end
2
+ class RowCount < Count
12
3
  end
13
4
  end
@@ -1,13 +1,4 @@
1
1
  module FiberUnits
2
- class StitchCount
3
- attr_reader :value
4
-
5
- def initialize(value, _unit = nil)
6
- @value = value
7
- end
8
-
9
- def +(other)
10
- StitchCount.new(value + other.value)
11
- end
2
+ class StitchCount < Count
12
3
  end
13
4
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FiberUnits
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
data/lib/fiber_units.rb CHANGED
@@ -8,6 +8,7 @@ require_relative "fiber_units/conversions/weight_conversion"
8
8
 
9
9
  require_relative "fiber_units/dimensions/length"
10
10
  require_relative "fiber_units/dimensions/weight"
11
+ require_relative "fiber_units/dimensions/count"
11
12
  require_relative "fiber_units/dimensions/stitch_count"
12
13
  require_relative "fiber_units/dimensions/row_count"
13
14
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fiber_units
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Meagan Waller
@@ -28,6 +28,7 @@ files:
28
28
  - lib/fiber_units.rb
29
29
  - lib/fiber_units/conversions/length_conversion.rb
30
30
  - lib/fiber_units/conversions/weight_conversion.rb
31
+ - lib/fiber_units/dimensions/count.rb
31
32
  - lib/fiber_units/dimensions/length.rb
32
33
  - lib/fiber_units/dimensions/row_count.rb
33
34
  - lib/fiber_units/dimensions/stitch_count.rb