class LideoDao
Constants
- DB_FILE_NAME
- DB_FOLDER
- FULL_DB_FILE_PATH
- HOME_FOLDER
Public Class Methods
new()
click to toggle source
# File lib/lideo_dao.rb, line 9 def initialize db_folder_full_path = "#{HOME_FOLDER}/#{DB_FOLDER}" unless File.directory?(db_folder_full_path) FileUtils.mkdir_p(db_folder_full_path) end end
Public Instance Methods
all()
click to toggle source
# File lib/lideo_dao.rb, line 30 def all store = PStore.new(FULL_DB_FILE_PATH) list = [] store.transaction(true) do store.roots.map { |root| list << store[root] } end list end
delete_feed(url)
click to toggle source
# File lib/lideo_dao.rb, line 39 def delete_feed(url) PStore.new(FULL_DB_FILE_PATH).transaction do |store| raise ArgumentError, "Feed #{url} not found" if store[url].nil? store.delete(url) end end
find(group)
click to toggle source
# File lib/lideo_dao.rb, line 20 def find(group) store = PStore.new(FULL_DB_FILE_PATH) list = [] store.transaction(true) do store.roots .map { |root| list << store[root] if store[root].group == group } end list end
save(feed)
click to toggle source
# File lib/lideo_dao.rb, line 16 def save(feed) PStore.new(FULL_DB_FILE_PATH).transaction { |store| store[feed.url] = feed } end