class Bookscan::Cache
Public Instance Methods
books(group = nil)
click to toggle source
# File lib/bookscan/cache.rb, line 37 def books(group = nil) if group groups.each do |g| return g.books if g.hash == group end return {} else bs = Books.new groups.each do |g| g.books.each { |b| bs << b } end return bs end end
groups()
click to toggle source
# File lib/bookscan/cache.rb, line 8 def groups gs = nil transaction do |ps| gs = ps["groups"] end raise "No groups in cache. Exceute 'bookscan update' first." unless gs gs end
tuned()
click to toggle source
# File lib/bookscan/cache.rb, line 17 def tuned ts = nil transaction do |ps| ts = ps["tuned"] end ts_uniq = Books.new ts.each { |t| unless ts_uniq.find { |i| i.title == t.title } ts_uniq << t end } return ts_uniq.compact end
tuned?(book,type)
click to toggle source
# File lib/bookscan/cache.rb, line 31 def tuned?(book,type) b = tuned.by_id(book.book_id,type) return false unless b b.book_id == book.book_id and b.tune_type == type end