en14960 0.2.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bd8d12842a3b54fa5bcdd2c2386a23aac0a1c48c56ca71499355890ff213088e
4
- data.tar.gz: 4b0b49a18dc2f69ca5543c836f7651c8f080d40bfdc42ade1542ade68dc7828c
3
+ metadata.gz: 8dbb1531dc763837d2f9ddef55c5ae97ae4763b62bea5671d28a230b208c0fa1
4
+ data.tar.gz: c471b3628a2dc6cf1b4157c04ddf03724aa1ade11f354367bb8c1f31b4d0e522
5
5
  SHA512:
6
- metadata.gz: 27854d031bda2d5d2492848f23b8ca840911ef78656f334095c4fc3d9592258178120f9fdaa302a37279e0678b20caa12eb5ff7cb58d43c5856ad4129e2e697e
7
- data.tar.gz: 9b723fb971121fd27e4fb483196e1ae5146739b24fcbb62d23c39e724eecd2ab4bb92420f003536a2b7759310ddc83dc8be87c980b18fc24a12115424e77783b
6
+ metadata.gz: c035f45431a922e9b96260be0bd4bc9146adaa9aaf915554e63efa9bbf58889c1fee6a7793101ad9bd410d3483a40a28b771b29d24ffc913270153612204fccb
7
+ data.tar.gz: 16f3ce2f5a590a0e6668c98c5207f2fba589307d31ae90fee8602fcce7994105efdc5ec60022c774b4ee8a41fb1aff93bbb98232cd232ccba87a705c2d21021e
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EN14960
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  end
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.0
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-08-01 00:00:00.000000000 Z
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: