Sha256: f64073716b5f53e2c807949ff4b666e572273a12e8a92d3415642ae45ae0c324

Contents?: true

Size: 861 Bytes

Versions: 27

Compression:

Stored size: 861 Bytes

Contents

class Ppl::Command::Age < Ppl::Application::Command

  name        "age"
  description "List or show contacts's ages"

  attr_writer :list_format
  attr_writer :show_format

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

  def execute(input, output)
    action = determine_action(input)
    send(action, input, output)
  end


  private

  def determine_action(input)
    if input.arguments[0].nil?
      :list_ages
    else
      :show_age
    end
  end

  def list_ages(input, output)
    address_book = @storage.load_address_book
    formatted    = @list_format.process(address_book)
    output.line(formatted)
    return true
  end

  def show_age(input, output)
    contact   = @storage.require_contact(input.arguments.first)
    formatted = @show_format.process(contact)
    output.line(formatted)
    return true
  end

end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
ppl-1.18.0 lib/ppl/command/age.rb
ppl-1.17.2 lib/ppl/command/age.rb
ppl-1.17.1 lib/ppl/command/age.rb
ppl-1.17.0 lib/ppl/command/age.rb
ppl-1.16.0 lib/ppl/command/age.rb
ppl-1.15.1 lib/ppl/command/age.rb
ppl-1.15.0 lib/ppl/command/age.rb