weighable 1.2.0 → 1.2.1
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/lib/weighable/version.rb +1 -1
- data/lib/weighable/weight.rb +6 -5
- 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: 59590559bae37c9a8917af5d48557eb23f46c6bb
|
4
|
+
data.tar.gz: 427bd3b26282dbdf5a4b0a6d942f88e01289bce4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c708051394c9f605113a082143d34663deb83e5fd5f1f7c86b1c6efd2655a16ce82583340674b285b85e8e0e432eabb457109d84eb68726da93a712eae803cf7
|
7
|
+
data.tar.gz: d1c5fcafe0e8f6933f4ade09e505e46e9f1b5830abc33f2cb6eb546e1d50b40607ad15fd66852409e20ebf54fc00f088395bb8fdf9e71def20e61e9ed8056e8c
|
data/lib/weighable/version.rb
CHANGED
data/lib/weighable/weight.rb
CHANGED
@@ -107,19 +107,20 @@ module Weighable
|
|
107
107
|
}.freeze
|
108
108
|
|
109
109
|
def self.parse(string)
|
110
|
-
|
110
|
+
trimmed = string.strip
|
111
|
+
unit_start = trimmed.index(' ')
|
111
112
|
if unit_start
|
112
|
-
unit =
|
113
|
-
value =
|
113
|
+
unit = trimmed.slice!(unit_start + 1..-1)
|
114
|
+
value = trimmed.slice!(0..unit_start - 1)
|
114
115
|
from_value_and_unit(value, unit)
|
115
116
|
else
|
116
|
-
from_value_and_unit(
|
117
|
+
from_value_and_unit(trimmed, nil)
|
117
118
|
end
|
118
119
|
end
|
119
120
|
|
120
121
|
def self.from_value_and_unit(value, unit)
|
121
122
|
unit = parse_unit(unit)
|
122
|
-
fail ArgumentError, 'invalid weight' if unit.nil? || value.
|
123
|
+
fail ArgumentError, 'invalid weight' if unit.nil? || value.to_s.strip.empty?
|
123
124
|
Weight.new(value, unit)
|
124
125
|
end
|
125
126
|
|
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: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Trae Robrock
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|