Class: Ppl::Command::Ls

Inherits:
Application::Command show all
Defined in:
lib/ppl/command/ls.rb

Instance Attribute Summary collapse

Attributes inherited from Application::Command

#description, #name, #storage

Instance Method Summary collapse

Constructor Details

#initializeLs

Returns a new instance of Ls.



6
7
8
9
10
11
# File 'lib/ppl/command/ls.rb', line 6

def initialize
  @name        = "ls"
  @description = "List all contacts"

  @format = Ppl::Format::AddressBook::OneLine.new
end

Instance Attribute Details

#format=(value) ⇒ Object (writeonly)

Sets the attribute format

Parameters:

  • value

    the value to set the attribute format to.



4
5
6
# File 'lib/ppl/command/ls.rb', line 4

def format=(value)
  @format = value
end

Instance Method Details

#execute(input, output) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/ppl/command/ls.rb', line 17

def execute(input, output)
  address_book = @storage.load_address_book
  formatted    = @format.process(address_book)

  output.line(formatted)
  return true
end

#options(parser, options) ⇒ Object



13
14
15
# File 'lib/ppl/command/ls.rb', line 13

def options(parser, options)
  parser.banner = "usage: ppl ls"
end