Class: Bookscan::Books

Inherits:
Array
  • Object
show all
Defined in:
lib/bookscan/book.rb

Instance Method Summary collapse

Instance Method Details

#by_id(book_id, type = nil) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/bookscan/book.rb', line 31

def by_id(book_id,type = nil)
  each do |b|
    next if type and b.tune_type != type
    return b if b.book_id == book_id
  end
  nil
end

#has?(book_id) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
42
43
44
# File 'lib/bookscan/book.rb', line 39

def has?(book_id)
  each do |b|
    return true if b.book_id == book_id
  end
  false
end

#idsObject



23
24
25
26
27
28
29
# File 'lib/bookscan/book.rb', line 23

def ids
  a = Array.new
  each do |b|
    a << b.book_id
  end
  a
end

#to_sObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/bookscan/book.rb', line 11

def to_s
  table = Mutter::Table.new(:delimiter => '|') do
    column :style => :green
    column :width => 100
  end

  each do |b|
    table << [b.book_id,b.title_short]
  end
  table.to_s if length > 0
end