Sha256: a1bd419d7314bad711c7c781289e0029b4e81c4a68454ef191b5aca617093f20

Contents?: true

Size: 627 Bytes

Versions: 1

Compression:

Stored size: 627 Bytes

Contents

require "thor"
require "punky_brewster"

module PunkyBrewster
  class CLI < Thor
    map "--version" => :version

    desc "version", "Show version"
    def version
      say "Punky Brewster version #{VERSION}"
    end

    desc "list", "Show current beer list"
    method_option :sort, default: "name", enum: %w( name price abv )
    def list
      beers = BeerListRequest.new.beers
      sorted = beers.sort_by { |beer| beer.send(options[:sort]) }

      rows = sorted.map do |beer|
        [beer.name, "$%0.2f/L" % beer.price, "%0.1f%" % beer.abv]
      end

      print_table rows
    end

    default_task :list
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
punky_brewster-1.2.0 lib/punky_brewster/cli.rb