Class: CachedItem
- Inherits:
-
Object
- Object
- CachedItem
- Defined in:
- lib/feed2imap/cache.rb
Overview
This class is the only thing kept in the cache
Instance Attribute Summary collapse
-
#creator ⇒ Object
readonly
Returns the value of attribute creator.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
-
#index ⇒ Object
Returns the value of attribute index.
-
#link ⇒ Object
readonly
Returns the value of attribute link.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#updated ⇒ Object
Returns the value of attribute updated.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #create_index ⇒ Object
-
#initialize(item) ⇒ CachedItem
constructor
A new instance of CachedItem.
- #is_ancestor_of(other) ⇒ Object
- #simple_compare(other) ⇒ Object
- #to_s ⇒ Object
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
#creator ⇒ Object (readonly)
Returns the value of attribute creator.
255 256 257 |
# File 'lib/feed2imap/cache.rb', line 255 def creator @creator end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
255 256 257 |
# File 'lib/feed2imap/cache.rb', line 255 def date @date end |
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
255 256 257 |
# File 'lib/feed2imap/cache.rb', line 255 def hash @hash end |
#index ⇒ Object
Returns the value of attribute index.
256 257 258 |
# File 'lib/feed2imap/cache.rb', line 256 def index @index end |
#link ⇒ Object (readonly)
Returns the value of attribute link.
255 256 257 |
# File 'lib/feed2imap/cache.rb', line 255 def link @link end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
255 256 257 |
# File 'lib/feed2imap/cache.rb', line 255 def title @title end |
#updated ⇒ Object
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_index ⇒ Object
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_s ⇒ Object
299 300 301 |
# File 'lib/feed2imap/cache.rb', line 299 def to_s "\"#{@title}\" #{@creator}/#{@date} #{@link} #{@hash}" end |