Class: Alx::ShowHandler

Inherits:
Handler show all
Defined in:
lib/alx/show_handler.rb

Instance Attribute Summary

Attributes inherited from Handler

#command_name

Instance Method Summary collapse

Methods inherited from Handler

#help

Constructor Details

#initialize(configuration) ⇒ ShowHandler

Returns a new instance of ShowHandler.



8
9
10
11
12
13
14
15
# File 'lib/alx/show_handler.rb', line 8

def initialize( configuration )
  super(
    :configuration => configuration,
    :command => 'show',
    :rest_description => 'pattern',
    :description => "Shows book matching the given pattern.",
    :options => [ :html, :stdout ] )
end

Instance Method Details

#handleObject



17
18
19
20
21
# File 'lib/alx/show_handler.rb', line 17

def handle
  parse_options
  options_error( "No pattern given. Please provide one." ) if @conf[ :rest ].empty?
  load_library.list( @conf[ :rest ] ).each { | book | show_book( book ) }
end