Created
April 18, 2010 16:22
-
-
Save gbuesing/370329 to your computer and use it in GitHub Desktop.
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
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