class Ppl::Command::Attribute
Attributes
attribute[W]
list_format[W]
show_format[W]
Public Instance Methods
execute(input, output)
click to toggle source
# File lib/ppl/command/attribute.rb, line 7 def execute(input, output) action = determine_action(input) send(action, input, output) end
Private Instance Methods
add_attribute(input, output)
click to toggle source
# File lib/ppl/command/attribute.rb, line 42 def add_attribute(input, output) contact = @storage.require_contact(input.arguments[0]) values = contact.send(@attribute) values.push(input.arguments[1].dup) @storage.save_contact(contact) true end
determine_action(input)
click to toggle source
# File lib/ppl/command/attribute.rb, line 15 def determine_action(input) if input.arguments[0].nil? :list_attribute elsif input.arguments[1].nil? :show_attribute elsif input.options[:delete] :remove_attribute else :add_attribute end end
list_attribute(input, output)
click to toggle source
# File lib/ppl/command/attribute.rb, line 27 def list_attribute(input, output) address_book = @storage.load_address_book if input.options[:no_color] @list_format.disable_colors! end output.line(@list_format.process(address_book)) true end
remove_attribute(input, output)
click to toggle source
# File lib/ppl/command/attribute.rb, line 50 def remove_attribute(input, output) contact = @storage.require_contact(input.arguments[0]) values = contact.send(@attribute) values.delete(input.arguments[1]) @storage.save_contact(contact) end
show_attribute(input, output)
click to toggle source
# File lib/ppl/command/attribute.rb, line 36 def show_attribute(input, output) contact = @storage.require_contact(input.arguments[0]) output.line(@show_format.process(contact)) true end