class Klipbook::Commands::Command
Attributes
logger[R]
Public Class Methods
new(logger=Logger.new)
click to toggle source
# File lib/klipbook/commands/command.rb, line 4 def initialize(logger=Logger.new) @logger = logger end
Public Instance Methods
run!(options)
click to toggle source
# File lib/klipbook/commands/command.rb, line 8 def run!(options) run_command!(book_source(options), options) end
run_command!()
click to toggle source
# File lib/klipbook/commands/command.rb, line 12 def run_command! raise "Implement me" end
Private Instance Methods
book_source(options)
click to toggle source
# File lib/klipbook/commands/command.rb, line 20 def book_source(options) Klipbook::Sources::Source.build(options) end
exit_unless_valid_count(options)
click to toggle source
# File lib/klipbook/commands/command.rb, line 31 def exit_unless_valid_count(options) unless options.count > 0 logger.error "Error: Specify a maximum book count greater than 0." exit 127 end end
exit_unless_valid_source(options)
click to toggle source
# File lib/klipbook/commands/command.rb, line 24 def exit_unless_valid_source(options) unless options.from_file logger.error "Error: You must specify `--from-file` as an input." exit 127 end end