Class: Klipbook::Commands::ListBooks
- Inherits:
-
Object
- Object
- Klipbook::Commands::ListBooks
- Defined in:
- lib/klipbook/commands/list_books.rb
Instance Method Summary collapse
- #call(output_stream = $stdout) ⇒ Object
-
#initialize(books) ⇒ ListBooks
constructor
A new instance of ListBooks.
Constructor Details
#initialize(books) ⇒ ListBooks
Returns a new instance of ListBooks.
3 4 5 |
# File 'lib/klipbook/commands/list_books.rb', line 3 def initialize(books) @books = books end |
Instance Method Details
#call(output_stream = $stdout) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/klipbook/commands/list_books.rb', line 7 def call(output_stream=$stdout) if @books.empty? output_stream.puts 'No books available' else output_stream.puts 'Book list:' @books.each_with_index do |book, index| output_stream.puts "[#{index + 1}] #{book.}" end end end |