class Myredditnews::History

Public Class Methods

new(path) click to toggle source
# File lib/myredditnews.rb, line 162
def initialize path
  @path         = path
  @posted_queue = []
  @db           = PStore.new(File.expand_path @path)
end

Public Instance Methods

append_entries!() click to toggle source
# File lib/myredditnews.rb, line 183
def append_entries!
  return if Myredditnews.dry
  @db.transaction do
    @posted_queue.each do |e|
      @db[e] = 0
    end
  end
end
delete_all!() click to toggle source
# File lib/myredditnews.rb, line 191
def delete_all!
  @db = nil
  File.delete @path if File.exists? @path
end
filter(entries) click to toggle source
# File lib/myredditnews.rb, line 167
def filter entries
  @db.transaction do
    entries.reject { |e| @db.root? e }
  end
end
posted!(entry) click to toggle source
# File lib/myredditnews.rb, line 180
def posted! entry
  @posted_queue << entry
end
posted?(entry) click to toggle source

TODO : the only reason this method was not removed is because it’s used in some tests

# File lib/myredditnews.rb, line 174
def posted? entry
  return true if @posted_queue.include? entry
  @db.transaction do
    @db.root? entry
  end
end