I've written it as this:

----
  def expiration_class(document)

    delta = Date.today - document.expiration_on

    result = case delta
        when 720..360: "doc_expired_360"
        when 360..90:  "doc_expired_90"
        when 90..60:   "doc_expired_60"
        when 60..30:   "doc_expired_30"
        when 30..1:    "doc_expired"
        else 'doc_current'
    end

  end
end
----

The problem, though, is that it's returning all deltas as "doc_current", 
when I know they're not.  Any ideas?


Frederick Cheung wrote:
> I might write this as
> delta = Date.today - document.expiration_on
> case delta
> when 720..360 then 'doc_expired_360'
> when 360..90 then 'doc_expired_90'
> 
> etc...
> 
> Fred

-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to