en14960 0.2.1 → 0.2.2
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/en14960/validators/play_area_validator.rb +22 -14
- data/lib/en14960/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: 80115ea696b28cdfdda43a16f3e7fc049db7a65ad15bfddef771706b92edbe73
|
4
|
+
data.tar.gz: afffd6182e680c35b983f88a5bf74324e3da7196a2d7f64e93f427a5e06bacf7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f50738aa5c9b3038c1b374bdedbe271b4541646d72db69c00c2f6535118241b4499687f5c775618c67a12bd25cbb92fe1573fdc9d3bc36144760bf80ed2f886
|
7
|
+
data.tar.gz: 07d08e86c3f7f95fc3e0047b0b0371c7445f8ad88057692dc0742fbe734a81e4abb74e9fe784452e7252df2e70b5c2f701b616492e08db21c9254fe06ba1174c
|
@@ -5,32 +5,40 @@ module EN14960
|
|
5
5
|
module PlayAreaValidator
|
6
6
|
extend self
|
7
7
|
|
8
|
-
def validate(
|
8
|
+
def validate(
|
9
|
+
unit_length:,
|
10
|
+
unit_width:,
|
11
|
+
play_area_length:,
|
12
|
+
play_area_width:,
|
13
|
+
negative_adjustment_area:
|
14
|
+
)
|
9
15
|
errors = []
|
10
16
|
|
11
|
-
|
12
|
-
|
13
|
-
|
17
|
+
if [
|
18
|
+
unit_length,
|
19
|
+
unit_width,
|
20
|
+
play_area_length,
|
21
|
+
play_area_width,
|
22
|
+
negative_adjustment_area
|
23
|
+
].any?(&:nil?)
|
24
|
+
errors << "All measurements must be provided"
|
14
25
|
end
|
15
26
|
|
16
|
-
# Return early if we have nil values
|
17
27
|
return build_response(false, errors) unless errors.empty?
|
18
28
|
|
19
|
-
# Convert all to floats for comparison
|
20
29
|
unit_length = unit_length.to_f
|
21
|
-
|
30
|
+
unit_width = unit_width.to_f
|
22
31
|
play_area_length = play_area_length.to_f
|
23
32
|
play_area_width = play_area_width.to_f
|
24
33
|
negative_adjustment_area = negative_adjustment_area.to_f
|
25
34
|
|
26
|
-
|
27
|
-
|
28
|
-
errors << "Play area length (#{play_area_length}) must be less than unit height (#{unit_height})"
|
35
|
+
if play_area_length > unit_length
|
36
|
+
errors << "Play area length (#{play_area_length}) must be less than or equal to unit length (#{unit_length})"
|
29
37
|
end
|
30
38
|
|
31
|
-
# Check play area width is less than unit
|
32
|
-
if play_area_width
|
33
|
-
errors << "Play area width (#{play_area_width}) must be less than unit
|
39
|
+
# Check play area width is less than unit width
|
40
|
+
if play_area_width > unit_width
|
41
|
+
errors << "Play area width (#{play_area_width}) must be less than or equal to unit width (#{unit_width})"
|
34
42
|
end
|
35
43
|
|
36
44
|
# Calculate total play area
|
@@ -43,7 +51,7 @@ module EN14960
|
|
43
51
|
|
44
52
|
build_response(errors.empty?, errors, {
|
45
53
|
unit_length: unit_length,
|
46
|
-
|
54
|
+
unit_width: unit_width,
|
47
55
|
play_area_length: play_area_length,
|
48
56
|
play_area_width: play_area_width,
|
49
57
|
total_play_area: total_play_area,
|
data/lib/en14960/version.rb
CHANGED