en14960 0.1.8 → 0.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/en14960/calculators/slide_calculator.rb +21 -11
- data/lib/en14960/validators/play_area_validator.rb +65 -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: 8dbb1531dc763837d2f9ddef55c5ae97ae4763b62bea5671d28a230b208c0fa1
|
4
|
+
data.tar.gz: c471b3628a2dc6cf1b4157c04ddf03724aa1ade11f354367bb8c1f31b4d0e522
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c035f45431a922e9b96260be0bd4bc9146adaa9aaf915554e63efa9bbf58889c1fee6a7793101ad9bd410d3483a40a28b771b29d24ffc913270153612204fccb
|
7
|
+
data.tar.gz: 16f3ce2f5a590a0e6668c98c5207f2fba589307d31ae90fee8602fcce7994105efdc5ec60022c774b4ee8a41fb1aff93bbb98232cd232ccba87a705c2d21021e
|
@@ -144,23 +144,33 @@ module EN14960
|
|
144
144
|
}
|
145
145
|
when (thresholds[:basic_walls]..thresholds[:enhanced_walls])
|
146
146
|
required_height = (user_height * enhanced_multiplier).round(2)
|
147
|
-
breakdown = [
|
148
|
-
["Height range", "3.0m - 6.0m"],
|
149
|
-
["Calculation", "#{user_height}m × #{enhanced_multiplier} = #{required_height}m"],
|
150
|
-
["Alternative requirement", "Permanent roof (can replace heightened walls)"]
|
151
|
-
]
|
152
147
|
|
153
|
-
#
|
154
|
-
if
|
155
|
-
breakdown
|
148
|
+
# Skip wall height requirement message if permanent roof is present
|
149
|
+
if has_permanent_roof
|
150
|
+
breakdown = [
|
151
|
+
["Height range", "3.0m - 6.0m"],
|
152
|
+
["Wall requirement", "#{required_height}m (1.25× user height) - skipped due to permanent roof"],
|
153
|
+
["Alternative requirement", "Permanent roof (can replace heightened walls)"],
|
156
154
|
["Permanent roof", "Fitted ✓"]
|
157
|
-
|
158
|
-
|
155
|
+
]
|
156
|
+
text = "Permanent roof fitted - wall height requirement satisfied"
|
157
|
+
else
|
158
|
+
breakdown = [
|
159
|
+
["Height range", "3.0m - 6.0m"],
|
160
|
+
["Calculation", "#{user_height}m × #{enhanced_multiplier} = #{required_height}m"],
|
161
|
+
["Alternative requirement", "Permanent roof (can replace heightened walls)"]
|
162
|
+
]
|
163
|
+
|
164
|
+
# Add roof status if known
|
165
|
+
if !has_permanent_roof.nil?
|
166
|
+
breakdown << ["Permanent roof", "Not fitted ✗"]
|
159
167
|
end
|
168
|
+
|
169
|
+
text = "Walls must be at least #{required_height}m (1.25× user height)"
|
160
170
|
end
|
161
171
|
|
162
172
|
{
|
163
|
-
text:
|
173
|
+
text: text,
|
164
174
|
breakdown: breakdown
|
165
175
|
}
|
166
176
|
when (thresholds[:enhanced_walls]..thresholds[:max_safe_height])
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EN14960
|
4
|
+
module Validators
|
5
|
+
module PlayAreaValidator
|
6
|
+
extend self
|
7
|
+
|
8
|
+
def validate(unit_length:, unit_height:, play_area_length:, play_area_width:, negative_adjustment_area:)
|
9
|
+
errors = []
|
10
|
+
|
11
|
+
# Check for nil values
|
12
|
+
if [unit_length, unit_height, play_area_length, play_area_width, negative_adjustment_area].any?(&:nil?)
|
13
|
+
errors << "All measurements must be provided (non-nil)"
|
14
|
+
end
|
15
|
+
|
16
|
+
# Return early if we have nil values
|
17
|
+
return build_response(false, errors) unless errors.empty?
|
18
|
+
|
19
|
+
# Convert all to floats for comparison
|
20
|
+
unit_length = unit_length.to_f
|
21
|
+
unit_height = unit_height.to_f
|
22
|
+
play_area_length = play_area_length.to_f
|
23
|
+
play_area_width = play_area_width.to_f
|
24
|
+
negative_adjustment_area = negative_adjustment_area.to_f
|
25
|
+
|
26
|
+
# Check play area length is less than unit height
|
27
|
+
if play_area_length >= unit_height
|
28
|
+
errors << "Play area length (#{play_area_length}) must be less than unit height (#{unit_height})"
|
29
|
+
end
|
30
|
+
|
31
|
+
# Check play area width is less than unit length
|
32
|
+
if play_area_width >= unit_length
|
33
|
+
errors << "Play area width (#{play_area_width}) must be less than unit length (#{unit_length})"
|
34
|
+
end
|
35
|
+
|
36
|
+
# Calculate total play area
|
37
|
+
total_play_area = play_area_length * play_area_width
|
38
|
+
|
39
|
+
# Check total play area is more than negative adjustment area
|
40
|
+
if total_play_area <= negative_adjustment_area
|
41
|
+
errors << "Total play area (#{total_play_area}) must be greater than negative adjustment area (#{negative_adjustment_area})"
|
42
|
+
end
|
43
|
+
|
44
|
+
build_response(errors.empty?, errors, {
|
45
|
+
unit_length: unit_length,
|
46
|
+
unit_height: unit_height,
|
47
|
+
play_area_length: play_area_length,
|
48
|
+
play_area_width: play_area_width,
|
49
|
+
total_play_area: total_play_area,
|
50
|
+
negative_adjustment_area: negative_adjustment_area
|
51
|
+
})
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def build_response(valid, errors, measurements = {})
|
57
|
+
{
|
58
|
+
valid: valid,
|
59
|
+
errors: errors,
|
60
|
+
measurements: measurements
|
61
|
+
}
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
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.1
|
4
|
+
version: 0.2.1
|
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-
|
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:
|