Skip to content

Instantly share code, notes, and snippets.

@gbuesing
Created April 18, 2010 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gbuesing/370329 to your computer and use it in GitHub Desktop.
Save gbuesing/370329 to your computer and use it in GitHub Desktop.
require 'date'
class Article < Hash
def initialize(hsh={})
replace(hsh)
end
def ==(other)
if other.is_a?(Date)
self[:date] == other
else
super
end
end
end
articles = [
Article.new(:date => Date.new(2008)),
Article.new(:date => Date.new(2009)),
Article.new(:date => Date.new(2010))
]
p articles.index Date.new(2009)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment