class Bookscan::Groups
Public Instance Methods
book(book_id)
click to toggle source
# File lib/bookscan/groups.rb, line 46 def book(book_id) g = find do |g| g.books.has?(book_id) end return nil unless g g.books.by_id(book_id) end
by_hash(hash)
click to toggle source
# File lib/bookscan/groups.rb, line 16 def by_hash(hash) i = to_index(hash) return nil unless i at(i) end
hashes()
click to toggle source
# File lib/bookscan/groups.rb, line 8 def hashes h = Array.new each do |group| h << group.hash end h end
to_index(hash)
click to toggle source
# File lib/bookscan/groups.rb, line 22 def to_index(hash) each_index do |i| return i if hash == at(i).hash end nil end
to_s()
click to toggle source
# File lib/bookscan/groups.rb, line 29 def to_s table = Mutter::Table.new(:delimiter => '|') do column :style => :green column column column column column end # table << ["#","Date","num","price","status"] sort{ |a,b| a.date <=> b.date}.each do |group| table << group.to_a end table.to_s if length > 0 end