Oh man this is so sweet, my code is so clean now I could cry!!!
I store each claim in an array for each period: day, week, month,
year, alltime
So now I can use the | operator on a symbol my code is down to this...

a= {}
# build the update hash
claims.each_value do |v|
  # reset day every day
  a[:day|v]= 0

  if now.wday == 0 # Sunday
    # reset week
    a[:week|v]= 0
  end

  if now.day == 1 # first day of month
    # reset month
    a[:month|v]= 0
  end

  if now.month == 1 && now.day == 1 # first day of year
    # reset year
    a[:year|v]= 0
  end
end

stats.update(a)

Can't get simpler than that!

Thanks.

On Dec 14, 1:47 pm, Jim Morris <[EMAIL PROTECTED]> wrote:
> Ok seems to work great if I use | instead of / maybe you should update
> the Changelog as there are two entries for it :) one saying use / one
> saying use | (I think | is better BTW)
>
> Thanks
>
> On Dec 14, 1:07 pm, Jim Morris <[EMAIL PROTECTED]> wrote:
>
> > Excellent I'll give it a try. Thanks.
>
> > On Dec 14, 5:54 am, Sharon Rosner <[EMAIL PROTECTED]> wrote:
>
> > > On Dec 14, 3:07 am, Jim Morris <[EMAIL PROTECTED]> wrote:
>
> > > > Is there support for the postgresql data type array? (or SQL Array)?
>
> > > I've added support for subscript access using the / operator on
> > > symbols, e.g.:
>
> > >   DB[:stats].select(:user_id, (:year/1).as(:value)).where {:year/1 >
> > > 0}.sql
> > >   #=> "SELECT user_id, year[1] AS value FROM stats WHERE (year[1] >
> > > 0)"
>
> > > Symbol#[] is used for notating functions, which are - I believe - much
> > > more frequently used than subscript access. Anyway it's there in the
> > > trunk if you want to give it a go.
>
> > > sharon
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to