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 +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/fiber_units/dimensions/count.rb +48 -0
- data/lib/fiber_units/dimensions/row_count.rb +1 -10
- data/lib/fiber_units/dimensions/stitch_count.rb +1 -10
- data/lib/fiber_units/version.rb +1 -1
- data/lib/fiber_units.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b852a73832747576078a185f9e3fab2a926fd9836d4df9b6a6ce05e2f5718436
|
|
4
|
+
data.tar.gz: 37e5f5208b1c12a13d9c1f01a30d87f7508520df120c4c99bc9fd1810a73bbb1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
data/lib/fiber_units/version.rb
CHANGED
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.
|
|
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
|