lib/punky_brewster/cli.rb in punky_brewster-1.3.1 vs lib/punky_brewster/cli.rb in punky_brewster-1.3.2
- old
+ new
@@ -15,19 +15,19 @@
method_option :cheapskate, type: :boolean, default: false
method_option :holla_for_dollar, type: :boolean, default: false
def list
show_abv_per_dollar = options[:holla_for_dollar] || options[:cheapskate]
- beers = BeerListRequest.new.beers
+ beers = BeerRepository.list
if options[:holla_for_dollar]
sorted = beers.sort { |a, b| b.abv_per_dollar <=> a.abv_per_dollar }
else
sorted = beers.sort_by { |beer| beer.send(options[:sort]) }
end
rows = sorted.map do |beer|
- row = [beer.name, "$%0.2f/L" % beer.price, "%0.1f%" % beer.abv]
+ row = [beer.name, "$%0.2f/L" % beer.price, "%0.1f%%" % beer.abv]
row << ("%0.2f%%/$" % beer.abv_per_dollar) if show_abv_per_dollar
row
end
print_table rows