physical 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de7fabfb964fcae3c3c6beaff9910aaab0c00ca3
|
4
|
+
data.tar.gz: 33c951d1c9d9dae5d3147b7a21485d127a0e843b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 573c585f62bf8829a4dd12c2b8b110152a21fe0fa340f34cb567ecf82bbde2ba70dbfb5ab11c7cdd94b350904014f9b3c257257a112daa6f444d2396170493c3
|
7
|
+
data.tar.gz: 186ee3032e9582f736cf698a5dd5c0ba9a23c340f65ddb46c3895736db9b90ae1b5b039ded12f2bf4da70ca9c55c8680cc5b592d0dd0f005a7aa5acbf9f0d4a9
|
data/lib/physical/cuboid.rb
CHANGED
@@ -25,6 +25,27 @@ module Physical
|
|
25
25
|
|
26
26
|
private
|
27
27
|
|
28
|
+
NORMALIZED_METHOD_REGEX = /(\w+)\??$/
|
29
|
+
|
30
|
+
def method_missing(method)
|
31
|
+
symbolized_properties = properties.symbolize_keys
|
32
|
+
method_name = normalize_method_name(method)
|
33
|
+
if symbolized_properties.key?(method_name)
|
34
|
+
symbolized_properties[method_name]
|
35
|
+
else
|
36
|
+
super
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def respond_to_missing?(method, *args)
|
41
|
+
method_name = normalize_method_name(method)
|
42
|
+
properties.symbolize_keys.key?(method_name) || super
|
43
|
+
end
|
44
|
+
|
45
|
+
def normalize_method_name(method)
|
46
|
+
method.to_s.sub(NORMALIZED_METHOD_REGEX, '\1').to_sym
|
47
|
+
end
|
48
|
+
|
28
49
|
def fill_dimensions(dimensions)
|
29
50
|
dimensions.fill(dimensions.length..2) do |index|
|
30
51
|
@dimensions[index] || Measured::Length(self.class::DEFAULT_LENGTH, :cm)
|
data/lib/physical/package.rb
CHANGED
@@ -17,10 +17,12 @@ module Physical
|
|
17
17
|
def <<(item)
|
18
18
|
@items.add(item)
|
19
19
|
end
|
20
|
+
alias_method :add, :<<
|
20
21
|
|
21
22
|
def >>(item)
|
22
23
|
@items.delete(item)
|
23
24
|
end
|
25
|
+
alias_method :delete, :>>
|
24
26
|
|
25
27
|
def weight
|
26
28
|
container.weight + items.map(&:weight).reduce(Measured::Weight(0, :g), &:+) + void_fill_weight
|
data/lib/physical/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: physical
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Meyerhoff
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: carmen
|