Module: Gibbler::DateTime

Includes:
Object
Included in:
DateTime
Defined in:
lib/gibbler.rb

Overview

Creates a digest based on: CLASS:LENGTH:DATETIME. Dates are calculated based on the equivalent datetime in UTC. e.g.

DateTime.parse('2009-08-25T17:00:40+00:00')  => ad64c769
DateTime.parse('2009-08-25T13:00:40-04:00')  => ad64c769

To use use method in other classes simply:

class ClassLikeTime 
  include Gibbler::Time
end

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Object

#gibbled?, #gibbler, #gibbler_debug

Class Method Details

.included(obj) ⇒ Object



309
310
311
312
# File 'lib/gibbler.rb', line 309

def self.included(obj)
  obj.extend Attic
  obj.attic :__gibbler_cache
end

Instance Method Details

#__gibbler(h = self) ⇒ Object

Creates a digest for the current state of self.



315
316
317
318
319
320
321
# File 'lib/gibbler.rb', line 315

def __gibbler(h=self)
  klass = h.class
  value = h.nil? ? "\0" : h.new_offset(0).to_s
  a = Gibbler.digest "%s:%d:%s" % [klass, value.size, value]
  gibbler_debug klass, a, [klass, value.size, value]
  a
end