on_calendar 0.1.4 → 0.1.5
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/on_calendar/condition/base.rb +11 -12
- data/lib/on_calendar/version.rb +1 -1
- 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: cbe9db161db861f5edf1b22f387b777d45b74bfafae76a610250d72c0ed03cb5
|
|
4
|
+
data.tar.gz: b140a57e6f03980d831c7481874d1c2f157afa70248ad46d3e58e8afd92b8367
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c97cff133a4d9bfd98a850b446a131fadd9b3cbfeba8c1117f478232475ca64a81457934429fa5dac4c48f88c295e0af1ef3fa5a2ebb7d4ffc2a50a0a37e03a0
|
|
7
|
+
data.tar.gz: fc22df7427d197da05e589a2ee2c9f86c2ea57cee7a7225573e5bf8d5d43050cbdd813c498315d83e448274c521f69c58ab0cd60d9ec286df306471138c9a4fe
|
|
@@ -75,7 +75,8 @@ module OnCalendar
|
|
|
75
75
|
|
|
76
76
|
return nil if needle_index.nil?
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
# Default to increment value by 1
|
|
79
|
+
distance = 1
|
|
79
80
|
|
|
80
81
|
if step.nil?
|
|
81
82
|
# If we are dealing with a range and the current and current+1 within range
|
|
@@ -106,17 +107,15 @@ module OnCalendar
|
|
|
106
107
|
target_index = arr.index(next_value)
|
|
107
108
|
end
|
|
108
109
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
distance = arr.length - needle_index
|
|
119
|
-
end
|
|
110
|
+
# Lets work out distance between target_index and needle_index
|
|
111
|
+
if !target_index.nil? && needle_index < target_index
|
|
112
|
+
# If the needle is before target get how many steps we need to step
|
|
113
|
+
distance = target_index - needle_index
|
|
114
|
+
else
|
|
115
|
+
# If is in front of us loop over until start of array
|
|
116
|
+
# Note: This sounds counter intuitive - why not give the distance until the next value
|
|
117
|
+
# However this forces us to re-evaluate all other date parts otherwise we might jump forward too far
|
|
118
|
+
distance = arr.length - needle_index
|
|
120
119
|
end
|
|
121
120
|
distance
|
|
122
121
|
end
|
data/lib/on_calendar/version.rb
CHANGED