Sha256: 95b99ad6348e74710732c9a814e4a54aa19010fded65474563fa9fba5b035640
Contents?: true
Size: 941 Bytes
Versions: 3
Compression:
Stored size: 941 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) 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 end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
klipbook-0.2.1 | lib/klipbook/runner.rb |
klipbook-0.2.0 | lib/klipbook/runner.rb |
klipbook-0.1.0 | lib/klipbook/runner.rb |