Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Watchman assignment submission #30

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions db/migrate/201402171619_create_beers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class CreateBeers < ActiveRecord::Migration

def change
create_table :beers do |t|
t.string :name
t.string :country
t.string :brewer
t.string :kind_of
t.integer :rating
t.string :summary
t.timestamps
end
end
end
20 changes: 20 additions & 0 deletions db/seed.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
# Cleaning Out
Network.delete_all
Show.delete_all
Beer.delete_all

amc = Network.create(name: "AMC")
nbc = Network.create(name: "NBC")
cine = Network.create(name: "Cinemax")
usa = Network.create(name: "USA Network")
netflix = Network.create(name: "Netflix")
sho = Network.create(name: "Showtime")
Show.create(name: "Mad Men", day_of_week: "Sunday", hour_of_day: 22, network: amc)
Show.create(name: "Community", day_of_week: "Thursday", hour_of_day: 20, network: nbc)
Show.create(name: "Breaking Bad", day_of_week: "Sunday", hour_of_day: 22, network: amc)
Show.create(name: "Banshee", day_of_week: "Friday", hour_of_day: 22, network: cine)
Show.create(name: "Suits", day_of_week: "Thursday", hour_of_day: 21, network: usa)
Show.create(name: "House of Cards", day_of_week: "Friday", hour_of_day: 20, network: netflix)
Show.create(name: "House of Lies", day_of_week: "Sunday", hour_of_day: 22, network: sho)

Beer.create(name: 'Nova Schin', country: 'Brazil', brewer: ' Brasil Kirin', kind_of: 'Pilsner', rating: 5, summary:'Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed')
Beer.create(name: 'Tusker', country: 'Kenya', brewer: 'East African Breweries', kind_of: 'Lager', rating: 4, summary: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ...')
Beer.create(name: 'Tui', country: 'New Zealand', brewer: 'DB Breweries', kind_of: 'Indian Pale Ale', rating: 4, summary: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ...')
Beer.create(name: 'Victoria Bitter', country: 'Australian', brewer: 'Carlton & United Breweries, Ltd', kind_of: 'Lager', rating: 1, summary: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ...')
Beer.create(name: 'Tiger', country: 'Singapore', brewer: 'Foo', kind_of: 'Lager', rating: 3, summary: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tsummary: incidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ...')
Beer.create(name: 'Sapporo', country: 'Japan', brewer: 'Sapporo Breweries Ltd', kind_of: 'Lager', rating: 2, summary: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ...')
Beer.create(name: 'Castle', country: 'South Africa', brewer: 'South African Breweries Ltd', kind_of: 'Lager', rating: 5, summary: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ...')
Beer.create(name: 'Windhoek', country: 'Namibia', brewer: 'Namibia Breweries', kind_of: 'Lager', rating: 2, summary: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ...')
10 changes: 10 additions & 0 deletions models/beer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class Beer < ActiveRecord::Base

def to_s
"\"#{name}\" , [#{kind_of}, #{country}, #{brewer}]"
end

def summarize
"#{name} is a #{kind_of} from #{country}.\n#{summary}.\nI rate it a #{rating} out of 5."
end
end
6 changes: 5 additions & 1 deletion models/show.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ class Show < ActiveRecord::Base

validates_presence_of :name

def self.by_day(day_of_week)
Show.where(:day_of_week => day_of_week)
end

def to_s
"#{name} airs at #{hour_of_day}:#{day_of_week}:00 on #{network} "
"#{name} airs at #{hour_of_day}:00 #{day_of_week} on #{network} "
end
end
31 changes: 30 additions & 1 deletion watchman.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,40 @@
Dir.glob('./models/*').each { |r| require r}
require "./db/seed"

puts "\n\nPanda Level\n"
puts "----------------------"
puts "There are #{Show.count} in the database"

Network.all.each do |network|
puts "Shows airing on #{network}"
network.shows.each do |show|
puts show
end
end
end

puts "\n\nTiger Level\n"
puts "----------------------"
puts "On which day would you like to watch TV?"
input = gets.chomp.titlecase
puts "On #{input.titlecase}s, you can watch:\n"
shows_list = Show.by_day(input)
shows_list.each do |show|
puts "#{show.name} at #{show.hour_of_day}:00 on #{show.network}"
end

puts "\n\nEagle (Advanced) Level\n"
puts "----------------------"
Beer.all.each do |beer|
puts beer
end

puts "\n\nWhat would you like to learn more about?"
input = gets.chomp.titlecase

beer = Beer.find_by_name(input)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AWESOME

if beer
puts "Did you know?\n"
puts beer.summarize
else
puts "Sorry, I can't do that right now."
end