jimweirich/texp

ruby2.0.0p195 include? return always false

Opened this issue · 5 comments

Would like to see if today (2013,6,6) is included in a texp for every Thursday in June.

june_six = Date.new(2013,6,6).thursday? # => true

include TExp::DSL
te = dow(4) * month(:jun) # => the day of the week is Thursday and the month is June
te.include?(june_six) # => false

Don't know why it says false.

Also...If i run this code from the Readme example:

#!/usr/bin/env ruby

require 'texp'
require 'date'

te = TExp::DayOfWeek.new(Date::DAYNAMES.index("Monday"))
p te.include?(TExp.parse("Mar 3, 2008"))    # => expecting true got false
p te.include?(Date.parse("Mar 4, 2008"))    # => false
p te.include?(Date.parse("Mar 10, 2008"))   # => expecting true got false

You are using include? (an Enumerable method), rather than includes? (the TExp method). A subtle difference that I'm not entirely happy with.

The TExp/HEAD version currently throws an exception when using include?. Maybe I should just allow both (overriding the Enumerable version). Or rename to a less confusing method name.

Oh, and TExp.parse("Mar 3, 2008") will not work. I assume that was just a typo.

FYI: I see there are a number of changes that haven't been pushed to the gem server. I made a quick release of 0.1.1 and am pushing the gem now. I think its time to review the code base and push for a 1.0 release of this gem.

OK, I just noticed that the README file uses "include?" rather than "includes?" (fixed now). Sorry about that.

Viable alternatives?

  • include_date?
  • incl?
  • comprise?
  • enclose?
  • has?

IMHO the "s" at the end is easy to forget but, maybe it's just me.