en14960 0.2.1 → 0.2.3
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
- data/lib/en14960.rb +9 -3
- 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: fedeb5f36f6f2e3f2ac74b39a18ad7ead640a520917d4681abe23403a477de7f
|
4
|
+
data.tar.gz: 62b331bcad579a79b39039ba9a4fc8a3f8a15bef7bdf785e4e336434253e0112
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0195422eb49e92201c750a030003620844f798426143b4ed8b58d80fd1ff277ae8e8d735bb2edea76ebf146b24669adf67a0750ebc1f81f7683e5de33cd782a
|
7
|
+
data.tar.gz: 8d0892f9d9c7522c43d4bfb8c7b16f80e947e8a36ea75b3126fcdf7e06470b3ecd6d6067a6515eec337fa739a2d98f9b218d3ad23b2ebae17a044494735ce223
|
@@ -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
data/lib/en14960.rb
CHANGED
@@ -83,15 +83,21 @@ module EN14960
|
|
83
83
|
|
84
84
|
# Validate play area measurements
|
85
85
|
# @param unit_length [Float] Unit length
|
86
|
-
# @param
|
86
|
+
# @param unit_width [Float] Unit width
|
87
87
|
# @param play_area_length [Float] Play area length
|
88
88
|
# @param play_area_width [Float] Play area width
|
89
89
|
# @param negative_adjustment_area [Float] Negative adjustment area
|
90
90
|
# @return [Hash] Validation result with errors and measurements
|
91
|
-
def validate_play_area(
|
91
|
+
def validate_play_area(
|
92
|
+
unit_length:,
|
93
|
+
unit_width:,
|
94
|
+
play_area_length:,
|
95
|
+
play_area_width:,
|
96
|
+
negative_adjustment_area:
|
97
|
+
)
|
92
98
|
Validators::PlayAreaValidator.validate(
|
93
99
|
unit_length: unit_length,
|
94
|
-
|
100
|
+
unit_width: unit_width,
|
95
101
|
play_area_length: play_area_length,
|
96
102
|
play_area_width: play_area_width,
|
97
103
|
negative_adjustment_area: negative_adjustment_area
|