fiber_units 0.1.0 → 0.2.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 +15 -0
- data/lib/fiber_units/measurement.rb +18 -0
- data/lib/fiber_units/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 82ac302d86901a24e9b0d6cd38cc5185978360173454fa13cdbacaa4c295e2de
|
|
4
|
+
data.tar.gz: 60d959472750dab825784939543b4e5ab1838b21173e069ca89ba1fe0290c82e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 78a95907d6a3b37167ac797f65e410a2c7f676fbb595f41b50b31089077bb21b99c4a113e0a6736637eb206d776f4190eb369838af9de2ef261f069004f71484
|
|
7
|
+
data.tar.gz: 77066078c243b350dd7bd144fa9452263105bb4bff9d0bc876e0a6f4ab304bea09e2bb6bdf5e8efda46de7985edf3738e9a104a3f8190597509ea1fb6417b80d
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [0.2.0] - 2026-03-09
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- Comparison operators (`<`, `>`, `<=`, `>=`, `==`, `!=`) for `Measurement` class
|
|
7
|
+
- Support for cross-unit comparisons (e.g., `4.inches > 10.centimeters`)
|
|
8
|
+
- Dimension safety checks in comparisons (raises error for incompatible units)
|
|
9
|
+
|
|
3
10
|
## [0.1.0] - 2026-03-09
|
|
4
11
|
|
|
12
|
+
### Added
|
|
13
|
+
- Core `Measurement` class for representing and manipulating fiber unit measurements
|
|
14
|
+
- Dimension types: `Length`, `Weight`, `RowCount`, and `StitchCount`
|
|
15
|
+
- Conversion framework with `LengthConversion` and `WeightConversion` support
|
|
16
|
+
- Unit operations: addition, subtraction, multiplication, and division
|
|
17
|
+
- `Ratio` class for expressing relationships between measurements
|
|
18
|
+
- Numeric extensions for DSL-style usage (e.g., `10.cm`, `100.grams`)
|
|
19
|
+
- Comprehensive RBS type signatures for type checking support
|
|
5
20
|
- Initial release
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
module FiberUnits
|
|
2
2
|
class Measurement
|
|
3
|
+
include Comparable
|
|
4
|
+
|
|
3
5
|
attr_reader :value, :unit
|
|
4
6
|
|
|
5
7
|
def initialize(value, unit)
|
|
@@ -39,6 +41,22 @@ module FiberUnits
|
|
|
39
41
|
end
|
|
40
42
|
end
|
|
41
43
|
|
|
44
|
+
def <=>(other)
|
|
45
|
+
ensure_same_dimension!(other)
|
|
46
|
+
to_base <=> other.to_base
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def ==(other)
|
|
50
|
+
return false unless other.is_a?(Measurement)
|
|
51
|
+
return false unless other.is_a?(self.class)
|
|
52
|
+
|
|
53
|
+
(to_base - other.to_base).abs < 1e-10
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def !=(other)
|
|
57
|
+
!(self == other)
|
|
58
|
+
end
|
|
59
|
+
|
|
42
60
|
def to(target_unit)
|
|
43
61
|
raise FiberUnits::InvalidUnitError unless self.class::FACTORS.key?(target_unit)
|
|
44
62
|
|
data/lib/fiber_units/version.rb
CHANGED