Class: Alx::AddHandler
Instance Attribute Summary
Attributes inherited from Handler
Instance Method Summary collapse
- #handle ⇒ Object
-
#initialize(configuration) ⇒ AddHandler
constructor
A new instance of AddHandler.
Methods inherited from Handler
Constructor Details
#initialize(configuration) ⇒ AddHandler
Returns a new instance of AddHandler.
7 8 9 10 11 12 13 14 |
# File 'lib/alx/add_handler.rb', line 7 def initialize( configuration ) super( :configuration => configuration, :command => 'add', :rest_description => 'book title', :description => "Adds new book to the library.", :options => [ :editor, :stdin ] ) end |
Instance Method Details
#handle ⇒ Object
16 17 18 19 20 21 |
# File 'lib/alx/add_handler.rb', line 16 def handle ( "No file name given. Please provide one." ) if @conf[ :rest ].empty? book_file_name = @conf[ :default_shelf_dir ] + "/" +@conf[ :rest ].gsub( / /, "_" ) Editor.new( @conf ).edit( book_file_name ) end |