Module: Gibbler::Range

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

Overview

Creates a digest based on: CLASS:EXCLUDE?:FIRST:LAST where EXCLUDE? is a boolean value whether the Range excludes the last value (i.e. 1…100) and FIRST and LAST are the values returned by Range#first and Range#last. e.g.

(1..100)   =>  Range:false:1:100  =>  54506352
(1...100)  =>  Range:true:1:100   =>  f0cad8cc

To use use method in other classes simply:

class ClassLikeRange 
  include Gibbler::Range
end

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Object

#digest_cache, #freeze, #gibbled?, #gibbler, #gibbler_debug, #gibbler_fields, gibbler_fields

Class Method Details

.included(obj) ⇒ Object



587
588
589
590
# File 'lib/gibbler.rb', line 587

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

Instance Method Details

#__gibbler(digest_type = nil) ⇒ Object

Creates a digest for the current state of self.



593
594
595
596
597
598
599
600
601
602
603
# File 'lib/gibbler.rb', line 593

def __gibbler(digest_type=nil)
  klass = self.class
  if self.nil? 
    first, last, exclude = "\0", "\0", "\0"
  else
    first, last, exclude = self.first, self.last, self.exclude_end?
  end
  a = Gibbler.digest "%s:%s:%s:%s" % [klass, exclude, first, last], digest_type
  gibbler_debug klass, a, [klass, exclude, first, last]
  a
end