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-3.0.1 lib/ppl/command/age.rb
ppl-3.0.0 lib/ppl/command/age.rb
ppl-2.4.1 lib/ppl/command/age.rb
ppl-2.4.0 lib/ppl/command/age.rb
ppl-2.3.3 lib/ppl/command/age.rb
ppl-2.3.2 lib/ppl/command/age.rb
ppl-2.3.1 lib/ppl/command/age.rb
ppl-2.3.0 lib/ppl/command/age.rb
ppl-2.2.0 lib/ppl/command/age.rb
ppl-2.1.0 lib/ppl/command/age.rb
ppl-2.0.0 lib/ppl/command/age.rb
ppl-1.25.0 lib/ppl/command/age.rb
ppl-1.24.0 lib/ppl/command/age.rb
ppl-1.23.0 lib/ppl/command/age.rb
ppl-1.22.2 lib/ppl/command/age.rb
ppl-1.22.1 lib/ppl/command/age.rb
ppl-1.22.0 lib/ppl/command/age.rb
ppl-1.21.0 lib/ppl/command/age.rb
ppl-1.20.0 lib/ppl/command/age.rb
ppl-1.19.0 lib/ppl/command/age.rb