Module: Gibbler::Time

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

Overview

Creates a digest based on: CLASS:LENGTH:TIME. Times are calculated based on the equivalent time in UTC. e.g.

Time.parse('2009-08-25 16:43:53 UTC')     => 73b4635f
Time.parse('2009-08-25 12:43:53 -04:00')  => 73b4635f

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



278
279
280
281
# File 'lib/gibbler.rb', line 278

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.



284
285
286
287
288
289
290
# File 'lib/gibbler.rb', line 284

def __gibbler(h=self)
  klass = h.class
  value = h.nil? ? "\0" : h.utc.strftime('%Y-%m-%d %H:%M:%S UTC')
  a = Gibbler.digest "%s:%d:%s" % [klass, value.size, value]
  gibbler_debug klass, a, [klass, value.size, value]
  a
end