Class: Klipbook::Commands::List

Inherits:
Command
  • Object
show all
Defined in:
lib/klipbook/commands/list.rb

Instance Method Summary collapse

Methods inherited from Command

#initialize, #run!

Constructor Details

This class inherits a constructor from Klipbook::Commands::Command

Instance Method Details

#run_command!(book_source, _options) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/klipbook/commands/list.rb', line 4

def run_command!(book_source, _options)
  books = book_source.books
  if books.empty?
    logger.info 'No books available'
  else
    logger.info 'Book list:'
    books.each_with_index do |book, index|
      logger.info "[#{index + 1}] #{book.title_and_author}"
    end
  end
end