Skip to content

Commit 408e0b0

Browse files
committed
Modernize BYSETPOS commit
A few small updates to Nicolas Marlier's BYSETPOS support added in PR #349
1 parent 3e221e4 commit 408e0b0

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

lib/ice_cube/validations/monthly_by_set_pos.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module IceCube
33
module Validations::MonthlyBySetPos
44

55
def by_set_pos(*by_set_pos)
6-
return by_set_pos([by_set_pos]) if by_set_pos.is_a?(Fixnum)
6+
return by_set_pos([by_set_pos]) if by_set_pos.is_a?(Integer)
77

88
unless by_set_pos.nil? || by_set_pos.is_a?(Array)
99
raise ArgumentError, "Expecting Array or nil value for count, got #{by_set_pos.inspect}"
@@ -48,9 +48,7 @@ def validate(step_time, schedule)
4848
s.add_recurrence_rule IceCube::Rule.from_hash(rule.to_hash.reject{|k, v| [:by_set_pos, :count, :until].include? k})
4949
end
5050

51-
puts step_time
5251
occurrences = new_schedule.occurrences_between(start_of_month, end_of_month)
53-
p occurrences
5452
index = occurrences.index(step_time)
5553
if index == nil
5654
1

lib/ice_cube/validations/yearly_by_set_pos.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module IceCube
33
module Validations::YearlyBySetPos
44

55
def by_set_pos(*by_set_pos)
6-
return by_set_pos([by_set_pos]) if by_set_pos.is_a?(Fixnum)
6+
return by_set_pos([by_set_pos]) if by_set_pos.is_a?(Integer)
77

88
unless by_set_pos.nil? || by_set_pos.is_a?(Array)
99
raise ArgumentError, "Expecting Array or nil value for count, got #{by_set_pos.inspect}"

spec/examples/from_ical_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ module IceCube
8888

8989
it 'should be able to parse by_set_pos start (BYSETPOS)' do
9090
rule = IceCube::Rule.from_ical("FREQ=MONTHLY;BYDAY=MO,WE;BYSETPOS=-1,1")
91-
rule.should == IceCube::Rule.monthly.day(:monday, :wednesday).by_set_pos([-1, 1])
91+
expect(rule).to eq(IceCube::Rule.monthly.day(:monday, :wednesday).by_set_pos([-1, 1]))
9292
end
9393

9494
it 'should return no occurrences after daily interval with count is over' do

0 commit comments

Comments
 (0)