Why are only some methods of the Date class loaded without an explicit:
require \'date\'
line?
For example:
irb(mai
The Date class you are seeing is defined in lib/rubygems/specification.rb for compatibility reasons:
# date.rb can't be loaded for `make install` due to miniruby
# Date is needed for old gems that stored #date as Date instead of Time.
class Date; end
It's an empty class definition and it doesn't provide any methods or functionality.
If starting IRB without RubyGems, that Date class is gone:
$ ruby --disable-gems -S irb
irb(main):001:0> Date
NameError: uninitialized constant Date
The empty Date class was removed in RubyGems 2.4.0:
- RubyGems no longer defines an empty Date class. Pull Request #948 by Benoit Daloze.
Complementing @Stefan answer:
Please note that This has been removed, in later version of rubygems.