Class: Anemone::Page

Inherits:
Object show all
Defined in:
lib/hoodie/rash.rb

Instance Method Summary collapse

Instance Method Details

#to_hashObject



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/hoodie/rash.rb', line 75

def to_hash
  file  = ::File.basename(@url.to_s)
  key   = ::File.basename(file, '.*').downcase.to_sym
  type  = ::File.extname(file)[1..-1].downcase.to_sym
  id    = Hoodie::Obfuscate.befuddle(file, Digest::MD5.hexdigest(body.to_s))
  utime = Time::now.to_i
  key = { key => { type => {
    id:             id,
    cache_state:    state,
    file:           file,
    key:            key,
    type:           type,
    url:            @url.to_s,
    links:          links.map(&:to_s),
    code:           @code,
    visited:        @visited,
    depth:          @depth,
    referer:        @referer.to_s,
    fetched:        @fetched,
    utime:          utime,
    md5_digest:     Digest::MD5.hexdigest(body.to_s),
    sha256_digest:  Digest::SHA256.hexdigest(body.to_s)
  }}}
end