Class: Alx::ListHandler

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

Instance Attribute Summary

Attributes inherited from Handler

#command_name

Instance Method Summary collapse

Methods inherited from Handler

#help

Constructor Details

#initialize(configuration) ⇒ ListHandler

Returns a new instance of ListHandler.



6
7
8
9
10
11
12
# File 'lib/alx/list_handler.rb', line 6

def initialize( configuration )
  super(
    :configuration => configuration,
    :command => 'list',
    :rest_description => 'pattern',
    :description => "Lists matching books in the library. Lists all if there's no pattern given." )
end

Instance Method Details

#handleObject



14
15
16
17
# File 'lib/alx/list_handler.rb', line 14

def handle
  parse_options
  load_library.list( @conf[ :rest ] ).each { | book | puts book.title }
end