Sha256: 5e15431ef26afbbac1c012e07527a145c3d50cca2e94d4fe8eb3383365a61e2e
Contents?: true
Size: 962 Bytes
Versions: 1
Compression:
Stored size: 962 Bytes
Contents
module Klipbook class Runner def initialize(input_file) @clippings_file = Klipbook::ClippingsFile.new(input_file.read.strip) end def list_books(output=$stdout) if @clippings_file.books.empty? output.puts 'Your clippings file contains no books' else output.puts 'The list of books in your clippings file:' @clippings_file.books.each_with_index do |book, index| author = book.author ? " by #{book.author}" : '' output.puts "[#{index + 1}] #{book.title}#{author}" end end end def print_book_summary(book_number, output, options={}) if book_number < 1 or book_number > @clippings_file.books.length $stderr.puts "Sorry but you must specify a book index between 1 and #{@clippings_file.books.length}" return end book_summary = @clippings_file.books[book_number - 1] output.write book_summary.as_html(options) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
klipbook-0.3.0 | lib/klipbook/runner.rb |