weighable 0.8.1 → 0.9.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/.ruby-version +1 -1
- data/lib/weighable/version.rb +1 -1
- data/lib/weighable/weight.rb +7 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 466560269b82c5abdfb14f87cf477906cdcd791c
|
4
|
+
data.tar.gz: a1c58752b469af1c7ccc709ea7186028b67cddb8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7bc750cc906e88c464bd43aaef8bb47f5946eded3e14d5e98848a93ee4c820d840137ed96f71d3c69cc785199f8611c9d4425b15d9cc3e81d0e145bd51dd79dc
|
7
|
+
data.tar.gz: 387e334f16d5e0d0d9a398cfb3faa8783ecdeb6c7aa043ba1071488e266c8f30372a59a33b425e67f0ef521ceeb6567ea13d41eebb05329f4e40f42972f03a40
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.2.
|
1
|
+
2.2.8
|
data/lib/weighable/version.rb
CHANGED
data/lib/weighable/weight.rb
CHANGED
@@ -2,6 +2,8 @@ require 'active_support/inflector/methods'
|
|
2
2
|
|
3
3
|
module Weighable
|
4
4
|
class Weight
|
5
|
+
include Comparable
|
6
|
+
|
5
7
|
attr_reader :value, :unit
|
6
8
|
|
7
9
|
UNIT = {
|
@@ -191,6 +193,11 @@ module Weighable
|
|
191
193
|
@value >= other.value
|
192
194
|
end
|
193
195
|
|
196
|
+
def <=>(other)
|
197
|
+
other = other.to(unit_name)
|
198
|
+
@value <=> other.value
|
199
|
+
end
|
200
|
+
|
194
201
|
def round(precision = 0)
|
195
202
|
@value = @value.round(precision)
|
196
203
|
self
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: weighable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Trae Robrock
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -161,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
161
161
|
version: '0'
|
162
162
|
requirements: []
|
163
163
|
rubyforge_project:
|
164
|
-
rubygems_version: 2.4.5.
|
164
|
+
rubygems_version: 2.4.5.3
|
165
165
|
signing_key:
|
166
166
|
specification_version: 4
|
167
167
|
summary: Like BigDecimal, but for weight. Includes Rails integration.
|