Class: Bookscan::Cache
- Inherits:
-
PStore
- Object
- PStore
- Bookscan::Cache
- Defined in:
- lib/bookscan/cache.rb
Instance Method Summary collapse
Instance Method Details
#books(group = nil) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# 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 ⇒ Object
8 9 10 11 12 13 14 15 |
# 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 ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# 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) ⇒ Boolean
31 32 33 34 35 |
# 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 |