ruby-rails-extensions 2.1.2 → 2.2.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49b190ddafb371c08f8575f436b5413ccba9965dbd4a9da80b8c3452fcba4a20
|
4
|
+
data.tar.gz: ed03c3179e1a86ca4575056183189c6811a61ce579b6cb8e4fa2de3504ba539a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9724a504cf8200c514c942d5f85c1c1ac63f2fc6182719f0d209f9fc79096d68cb8d2746941215eab4e38b51f31df1f78b667b8ea058cbab0d7a266d200d251b
|
7
|
+
data.tar.gz: 1ba5c494a7752b5ca3d59ce9aec0e5a3eb648e0ae5591f2031fe72f1b5e258530890320fcea76e4e0ecc7ee3d2bb63e530f84a1baf4cb34fa6f9954be916c0c8
|
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Range
|
4
|
+
# Allows subtracting of a range.
|
5
|
+
#
|
6
|
+
# @raise [RubyRailsExtensions::Errors::NonNumericError] When trying to subtract from
|
7
|
+
# a range that isn't numeric, or the object isn't a numeric range, or the object
|
8
|
+
# isn't of numeric class.
|
9
|
+
#
|
10
|
+
# @note A new range will be created since ranges are immutable.
|
11
|
+
# This means you need to use `new_range = old_range - range/number`
|
12
|
+
# or `current_range -= range/number`.
|
13
|
+
#
|
14
|
+
# @param other [Range<Numeric>, Numeric]
|
15
|
+
#
|
16
|
+
# @return [Range]
|
17
|
+
#
|
18
|
+
def -(other)
|
19
|
+
unless self.begin.is_a?(Numeric)
|
20
|
+
raise(
|
21
|
+
RubyRailsExtensions::Errors::NonNumericError,
|
22
|
+
"Wrong range type (given #{self.begin.class}, expected Numeric)"
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
new_begin, new_end =
|
27
|
+
if other.is_a?(Range)
|
28
|
+
unless other.begin.is_a?(Numeric)
|
29
|
+
raise(
|
30
|
+
RubyRailsExtensions::Errors::NonNumericError,
|
31
|
+
"Wrong range type (given #{other.begin.class}, expected Numeric)"
|
32
|
+
)
|
33
|
+
end
|
34
|
+
|
35
|
+
[self.begin - other.begin, self.end - other.end]
|
36
|
+
else
|
37
|
+
unless other.is_a?(Numeric)
|
38
|
+
raise(
|
39
|
+
RubyRailsExtensions::Errors::NonNumericError,
|
40
|
+
"Wrong type (given #{other.class}, expected Numeric)"
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
44
|
+
[self.begin - other, self.end - other]
|
45
|
+
end
|
46
|
+
|
47
|
+
Range.new(new_begin, new_end, exclude_end?)
|
48
|
+
end
|
49
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-rails-extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brands Insurance
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- lib/ruby-rails-extensions/extensions/range_comparisons.rb
|
64
64
|
- lib/ruby-rails-extensions/extensions/range_multiply.rb
|
65
65
|
- lib/ruby-rails-extensions/extensions/range_round.rb
|
66
|
+
- lib/ruby-rails-extensions/extensions/range_subtract.rb
|
66
67
|
- lib/ruby-rails-extensions/extensions/remove_reserved_keywords.rb
|
67
68
|
- lib/ruby-rails-extensions/extensions/safe_parse.rb
|
68
69
|
- lib/ruby-rails-extensions/extensions/select_present.rb
|