This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Kernel | |
def with(obj, &block) | |
obj.instance_eval(&block) | |
end | |
end | |
with 'Hi' do | |
length # => 2 | |
upcase # => "HI" | |
downcase # => "hi" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window = 14 | |
latest = Time.parse('12:00 AM') | |
earliest = today - window.days | |
issues = Issue.find(:conditions => ['updated_at > ? AND updated_at < ?', yesterday, today]) | |
issues_by_day = Hash.new { |key| self[key] = [] } | |
issues_by_day = issues.injecting(issues_by_day) do |buckets, issue| | |
buckets[issue.updated_at.strftime('%m/%d')] << issue |
NewerOlder