Class: Ppl::Command::Add
- Inherits:
-
Application::Command
- Object
- Application::Command
- Ppl::Command::Add
- Defined in:
- lib/ppl/command/add.rb
Instance Attribute Summary collapse
-
#name_service ⇒ Object
writeonly
Sets the attribute name_service.
Attributes inherited from Application::Command
Instance Method Summary collapse
Methods inherited from Application::Command
Instance Attribute Details
#name_service=(value) ⇒ Object (writeonly)
Sets the attribute name_service
3 4 5 |
# File 'lib/ppl/command/add.rb', line 3 def name_service=(value) @name_service = value end |
Instance Method Details
#execute(input, output) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ppl/command/add.rb', line 12 def execute(input, output) contact_id = input.arguments.shift contact_name = input.arguments.shift if contact_id.nil? raise Ppl::Error::IncorrectUsage, "No contact specified" end if contact_name.nil? raise Ppl::Error::IncorrectUsage, "No name specified" end contact = Ppl::Entity::Contact.new contact.id = contact_id.dup contact.name = @name_service.parse contact_name.dup @storage.save_contact(contact) return true end |
#options(parser, options) ⇒ Object
8 9 10 |
# File 'lib/ppl/command/add.rb', line 8 def (parser, ) parser. = "usage: ppl add <contact> <name>" end |