-
-
Save mcfiredrill/cbf120e63fad37087195 to your computer and use it in GitHub Desktop.
This file contains 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
class NullDate | |
include Comparable | |
def to_s | |
"" | |
end | |
def <=> other_date | |
Time.new(0000,1,1) <=> other_date | |
end | |
def to_date | |
"" | |
end | |
def to_datetime | |
end | |
def strftime format | |
"No data yet." | |
end | |
# just in case... | |
def blank? | |
true | |
end | |
end |
This file contains 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
█▓▒░tony@matsuri░▒▓█ ~/src/app(development)$ irb | |
[1] pry(main)> require './lib/null_date' | |
=> true | |
[2] pry(main)> Time.new(2013,3,3) > NullDate.new | |
=> true | |
[3] pry(main)> NullDate.ancestors | |
=> [NullDate, Comparable, Object, PP::ObjectMixin, Kernel, BasicObject] | |
█▓▒░tony@matsuri░▒▓█ ~/src/app(development)$ ./script/rails c | |
Loading development environment (Rails 3.2.13) | |
[1] pry(main)> Time.new(2013,3,3) > NullDate.new | |
ArgumentError: comparison of Time with NullDate failed | |
from (pry):1:in `>' | |
[2] pry(main)> NullDate.ancestors | |
=> [NullDate, | |
Comparable, | |
Object, | |
Metaclass::ObjectMethods, | |
Mocha::ObjectMethods, | |
PP::ObjectMixin, | |
JSON::Ext::Generator::GeneratorMethods::Object, | |
ActiveSupport::Dependencies::Loadable, | |
Kernel, | |
BasicObject] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment