Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

table output

  • Loading branch information...
commit d9bd317fe968a08926f3c3a5c6bde8248337dd56 1 parent d3ceb9a
@cjolly authored
View
2  Gemfile.lock
@@ -3,6 +3,7 @@ PATH
specs:
pickem (0.0.1)
nokogiri
+ terminal-table
thor
GEM
@@ -18,6 +19,7 @@ GEM
rspec-expectations (2.6.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.6.0)
+ terminal-table (1.4.3)
thor (0.14.6)
PLATFORMS
View
7 lib/pickem.thor
@@ -1,5 +1,6 @@
$LOAD_PATH<<'.'
require 'pickem'
+require 'terminal-table'
module Pickem
class Picks < Thor
@@ -8,11 +9,7 @@ module Pickem
desc "for_week", "Suggestions for week "
def for_week(week_number)
week = ::Pickem::Week.new(week_number)
- puts "##Suggestions:\n\n"
- puts week.suggestions
- puts "\n"
- puts "##Games:\n\n"
- puts week.games
+ puts Terminal::Table.new :title => "Week #{week_number} Suggestions", :rows => week.suggestions
end
end
end
View
4 lib/pickem/game.rb
@@ -21,5 +21,9 @@ def favorite
@away
end
end
+
+ def underdog
+ favorite.name == away.name ? home : away
+ end
end
end
View
2  lib/pickem/week.rb
@@ -20,7 +20,7 @@ def sorted
def suggestions
suggestions = []
sorted.each_with_index do |g, i|
- suggestions << " #{16-i} - #{g.favorite}"
+ suggestions << [16-i, g.favorite.name, g.favorite.percent.to_s + '%', (g.favorite.name == g.home.name ? 'Home' : 'Away'), g.underdog.name]
end
suggestions
end
View
1  pickem.gemspec
@@ -21,4 +21,5 @@ Gem::Specification.new do |s|
s.add_development_dependency "rspec"
s.add_runtime_dependency "thor"
s.add_runtime_dependency "nokogiri"
+ s.add_runtime_dependency "terminal-table"
end
Please sign in to comment.
Something went wrong with that request. Please try again.