Class: CachedItem

Inherits:
Object
  • Object
show all
Defined in:
lib/feed2imap/cache.rb

Overview

This class is the only thing kept in the cache

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(item) ⇒ CachedItem

Returns a new instance of CachedItem.



259
260
261
262
263
264
265
266
267
268
269
# File 'lib/feed2imap/cache.rb', line 259

def initialize(item)
  @title = item.title
  @link = item.link
  @date = item.date
  @creator = item.creator
  if item.content.nil?
    @hash = nil
  else
    @hash = Digest::MD5.hexdigest(item.content.to_s)
  end
end

Instance Attribute Details

#creatorObject (readonly)

Returns the value of attribute creator.



255
256
257
# File 'lib/feed2imap/cache.rb', line 255

def creator
  @creator
end

#dateObject (readonly)

Returns the value of attribute date.



255
256
257
# File 'lib/feed2imap/cache.rb', line 255

def date
  @date
end

#hashObject (readonly)

Returns the value of attribute hash.



255
256
257
# File 'lib/feed2imap/cache.rb', line 255

def hash
  @hash
end

#indexObject

Returns the value of attribute index.



256
257
258
# File 'lib/feed2imap/cache.rb', line 256

def index
  @index
end

Returns the value of attribute link.



255
256
257
# File 'lib/feed2imap/cache.rb', line 255

def link
  @link
end

#titleObject (readonly)

Returns the value of attribute title.



255
256
257
# File 'lib/feed2imap/cache.rb', line 255

def title
  @title
end

#updatedObject

Returns the value of attribute updated.



257
258
259
# File 'lib/feed2imap/cache.rb', line 257

def updated
  @updated
end

Instance Method Details

#==(other) ⇒ Object



271
272
273
274
275
276
277
278
279
280
281
282
283
# File 'lib/feed2imap/cache.rb', line 271

def ==(other)
  if $updateddebug
    puts "Comparing #{self.to_s} and #{other.to_s}:"
    puts "Title: #{@title == other.title}"
    puts "Link: #{@link == other.link}"
    puts "Creator: #{@creator == other.creator}"
    puts "Date: #{@date == other.date}"
    puts "Hash: #{@hash == other.hash}"
  end
  @title == other.title and @link == other.link and
      (@creator.nil? or other.creator.nil? or @creator == other.creator) and
	(@date.nil? or other.date.nil? or @date == other.date) and @hash == other.hash
end

#create_indexObject



290
291
292
# File 'lib/feed2imap/cache.rb', line 290

def create_index
  @index = ItemCache.getindex
end

#is_ancestor_of(other) ⇒ Object



294
295
296
297
# File 'lib/feed2imap/cache.rb', line 294

def is_ancestor_of(other)
  (@link and other.link and @link == other.link) and
    ((@creator and other.creator and @creator == other.creator) or (@creator.nil?))
end

#simple_compare(other) ⇒ Object



285
286
287
288
# File 'lib/feed2imap/cache.rb', line 285

def simple_compare(other)
  @title == other.title and @link == other.link and
      (@creator.nil? or other.creator.nil? or @creator == other.creator) 
end

#to_sObject



299
300
301
# File 'lib/feed2imap/cache.rb', line 299

def to_s
  "\"#{@title}\" #{@creator}/#{@date} #{@link} #{@hash}"
end