weighable 0.6.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/weighable/version.rb +1 -1
- data/lib/weighable/weight.rb +6 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab98e294f2fca107af47cf5b27c13eb5d1a00ed0
|
4
|
+
data.tar.gz: aba32f7c95881c7cf21ae4c8f4b8e498cb83807e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22cfb1c699adfd3f7f08cc1b76674b64428420bdc60edc6b285159f6b4ffb0aee8e11647ed0e3bb379498c48ed0f61568de7d4639d92fcadb9546cd9c813bd8b
|
7
|
+
data.tar.gz: 8d8190bd122ea598661cf626edc66a6df70819218563523b8842997ad7d694d5397b3b42f3b7585652a1844165e77532fc83ff2b11d7efdb21427d8a307e7132
|
data/lib/weighable/version.rb
CHANGED
data/lib/weighable/weight.rb
CHANGED
@@ -22,7 +22,7 @@ module Weighable
|
|
22
22
|
unit: nil
|
23
23
|
}.freeze
|
24
24
|
|
25
|
-
|
25
|
+
ABBREVIATION_ALIASES = {
|
26
26
|
'g' => :gram,
|
27
27
|
'oz' => :ounce,
|
28
28
|
'lb' => :pound,
|
@@ -88,7 +88,7 @@ module Weighable
|
|
88
88
|
|
89
89
|
def self.parse(string)
|
90
90
|
value, unit = string.split(' ')
|
91
|
-
unit =
|
91
|
+
unit = ABBREVIATION_ALIASES[unit]
|
92
92
|
fail ArgumentError, 'invalid weight' if unit.nil?
|
93
93
|
Weight.new(value, unit)
|
94
94
|
end
|
@@ -185,6 +185,10 @@ module Weighable
|
|
185
185
|
self
|
186
186
|
end
|
187
187
|
|
188
|
+
def zero?
|
189
|
+
@value.zero?
|
190
|
+
end
|
191
|
+
|
188
192
|
private
|
189
193
|
|
190
194
|
def unit_name
|
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.7.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: 2016-
|
11
|
+
date: 2016-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|