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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0b3572ea68f262a1626b3185b2d13e79256725fd91c4fa5cdc889009fe1d7600
4
- data.tar.gz: e618f9e40bb5fadfbbe22df8a402579d22770847f276a5a962157e1ecbb67d9e
3
+ metadata.gz: cbe9db161db861f5edf1b22f387b777d45b74bfafae76a610250d72c0ed03cb5
4
+ data.tar.gz: b140a57e6f03980d831c7481874d1c2f157afa70248ad46d3e58e8afd92b8367
5
5
  SHA512:
6
- metadata.gz: 4e80eb72a14466acf35cb779b8914827ef09d72e606beb163123feee839c1adb1ceb6ee9486bce358812f4c68a5c79a13a9e41d54bd412d986f5a6cf4726cdd6
7
- data.tar.gz: 3dbb548925ef72560b394a5fb1379442a42b5363acec0fcea5bf032fe4e6451baa2e2b3914e99a2775daf31b8125dcb4e6dc59f3516433a2dc224ec4de231fca
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
- distance = 0
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
- unless target_index.nil?
110
- # Lets work out distance between target_index and needle_index
111
- if 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
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OnCalendar
4
- VERSION = "0.1.4"
4
+ VERSION = "0.1.5"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: on_calendar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Passmore