en14960 0.2.0 → 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 +73 -0
- data/lib/en14960/version.rb +1 -1
- data/lib/en14960.rb +18 -0
- metadata +3 -2
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
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EN14960
|
4
|
+
module Validators
|
5
|
+
module PlayAreaValidator
|
6
|
+
extend self
|
7
|
+
|
8
|
+
def validate(
|
9
|
+
unit_length:,
|
10
|
+
unit_width:,
|
11
|
+
play_area_length:,
|
12
|
+
play_area_width:,
|
13
|
+
negative_adjustment_area:
|
14
|
+
)
|
15
|
+
errors = []
|
16
|
+
|
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"
|
25
|
+
end
|
26
|
+
|
27
|
+
return build_response(false, errors) unless errors.empty?
|
28
|
+
|
29
|
+
unit_length = unit_length.to_f
|
30
|
+
unit_width = unit_width.to_f
|
31
|
+
play_area_length = play_area_length.to_f
|
32
|
+
play_area_width = play_area_width.to_f
|
33
|
+
negative_adjustment_area = negative_adjustment_area.to_f
|
34
|
+
|
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})"
|
37
|
+
end
|
38
|
+
|
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})"
|
42
|
+
end
|
43
|
+
|
44
|
+
# Calculate total play area
|
45
|
+
total_play_area = play_area_length * play_area_width
|
46
|
+
|
47
|
+
# Check total play area is more than negative adjustment area
|
48
|
+
if total_play_area <= negative_adjustment_area
|
49
|
+
errors << "Total play area (#{total_play_area}) must be greater than negative adjustment area (#{negative_adjustment_area})"
|
50
|
+
end
|
51
|
+
|
52
|
+
build_response(errors.empty?, errors, {
|
53
|
+
unit_length: unit_length,
|
54
|
+
unit_width: unit_width,
|
55
|
+
play_area_length: play_area_length,
|
56
|
+
play_area_width: play_area_width,
|
57
|
+
total_play_area: total_play_area,
|
58
|
+
negative_adjustment_area: negative_adjustment_area
|
59
|
+
})
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def build_response(valid, errors, measurements = {})
|
65
|
+
{
|
66
|
+
valid: valid,
|
67
|
+
errors: errors,
|
68
|
+
measurements: measurements
|
69
|
+
}
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
data/lib/en14960/version.rb
CHANGED
data/lib/en14960.rb
CHANGED
@@ -7,6 +7,7 @@ require_relative "en14960/calculators/anchor_calculator"
|
|
7
7
|
require_relative "en14960/calculators/slide_calculator"
|
8
8
|
require_relative "en14960/calculators/user_capacity_calculator"
|
9
9
|
require_relative "en14960/validators/material_validator"
|
10
|
+
require_relative "en14960/validators/play_area_validator"
|
10
11
|
require_relative "en14960/source_code"
|
11
12
|
|
12
13
|
# EN14960 provides calculators and validators for BS EN 14960:2019
|
@@ -79,5 +80,22 @@ module EN14960
|
|
79
80
|
def material_standards
|
80
81
|
Constants::MATERIAL_STANDARDS
|
81
82
|
end
|
83
|
+
|
84
|
+
# Validate play area measurements
|
85
|
+
# @param unit_length [Float] Unit length
|
86
|
+
# @param unit_height [Float] Unit height
|
87
|
+
# @param play_area_length [Float] Play area length
|
88
|
+
# @param play_area_width [Float] Play area width
|
89
|
+
# @param negative_adjustment_area [Float] Negative adjustment area
|
90
|
+
# @return [Hash] Validation result with errors and measurements
|
91
|
+
def validate_play_area(unit_length:, unit_height:, play_area_length:, play_area_width:, negative_adjustment_area:)
|
92
|
+
Validators::PlayAreaValidator.validate(
|
93
|
+
unit_length: unit_length,
|
94
|
+
unit_height: unit_height,
|
95
|
+
play_area_length: play_area_length,
|
96
|
+
play_area_width: play_area_width,
|
97
|
+
negative_adjustment_area: negative_adjustment_area
|
98
|
+
)
|
99
|
+
end
|
82
100
|
end
|
83
101
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: en14960
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chobble.com
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-08-
|
11
|
+
date: 2025-08-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -106,6 +106,7 @@ files:
|
|
106
106
|
- lib/en14960/models/calculator_response.rb
|
107
107
|
- lib/en14960/source_code.rb
|
108
108
|
- lib/en14960/validators/material_validator.rb
|
109
|
+
- lib/en14960/validators/play_area_validator.rb
|
109
110
|
- lib/en14960/version.rb
|
110
111
|
homepage: https://github.com/chobbledotcom/en14960
|
111
112
|
licenses:
|