C
Chris Roos
Hi,
I've just spent some time looking at an add_weekdays method on the Date
class.
My implementation is as follows.
class Date
def add_weekdays(days)
new_date = self
while days > 0
new_date += 1
days -= 1 unless (new_date.wday == 6 || new_date.wday == 0)
end
new_date
end
end
I'm interested to know whether I've a) wasted my time because I could
have achieved the same thing with an already available object/method b)
commited any ruby sins and c) whether there are much better ways of
implementing this?
Chris
I've just spent some time looking at an add_weekdays method on the Date
class.
My implementation is as follows.
class Date
def add_weekdays(days)
new_date = self
while days > 0
new_date += 1
days -= 1 unless (new_date.wday == 6 || new_date.wday == 0)
end
new_date
end
end
I'm interested to know whether I've a) wasted my time because I could
have achieved the same thing with an already available object/method b)
commited any ruby sins and c) whether there are much better ways of
implementing this?
Chris