-
Notifications
You must be signed in to change notification settings - Fork 27
Finished whole assignment to Eagle. #32
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,4 +3,4 @@ adapter: 'postgresql' | |
| database: 'watchman' | ||
| username: XXXXXXX | ||
| encoding: 'utf8' | ||
| pool: 5 | ||
| pool: 5 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| class CreateGames < ActiveRecord::Migration | ||
| def change | ||
| create_table :games do |t| | ||
| t.string :name | ||
| t.string :system | ||
| t.string :esrb_rating | ||
| t.string :studio | ||
| end | ||
| end | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,41 @@ | ||
| # Cleaning Out | ||
| Game.delete_all | ||
| Network.delete_all | ||
| Show.delete_all | ||
| # Declare Networks | ||
| amc = Network.create(name: "AMC") | ||
| nbc = Network.create(name: "NBC") | ||
| fx = Network.create(name: "FX") | ||
| bbca = Network.create(name: "BBC America") | ||
| # Add in shows | ||
| 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: "Archer", day_of_week: "Monday", hour_of_day: 19 , network: fx) | ||
| Show.create(name: "Dr. Who", day_of_week: "Wednesday", hour_of_day: 20, network: bbca) | ||
| # Add in games | ||
| # | ||
| # Xbox360 | ||
| Game.create(name: "Halo: Combat Evolved", system: "Xbox360", esrb_rating: "M", studio: "Bungie") | ||
| Game.create(name: "Dark Souls", system: "Xbox360", esrb_rating: "M", studio: "From Software") | ||
| Game.create(name: "Crysis", system: "Xbox360", esrb_rating: "M", studio: "Crytek Frankfurt") | ||
| Game.create(name: "Dragon Age: Origins", system: "Xbox360", esrb_rating: "M", studio: "Bioware") | ||
| # XboxOne | ||
| Game.create(name: "TitanFall", system: "XboxOne", esrb_rating: "M", studio: "Respawn Entertainment") | ||
| Game.create(name: "Ryse: Son of Rome", system: "XboxOne", esrb_rating: "M", studio: "Crytek") | ||
| Game.create(name: "Dead Rising 3", system: "XboxOne", esrb_rating: "M", studio: "Capcom") | ||
| Game.create(name: "Crimson Dragon", system: "XboxOne", esrb_rating: "M", studio: "Grounding Inc.") | ||
| # PS3 | ||
| Game.create(name: "The Last of Us", system: "PS3", esrb_rating: "M", studio: "Naughty Dog") | ||
| Game.create(name: "Assassins Creed IV: Black Flag", system: "PS3", esrb_rating: "M", studio: "Ubisoft") | ||
| Game.create(name: "Grand Theft Auto V", system: "PS3", esrb_rating: "M", studio: "Rockstar") | ||
| Game.create(name: "Metal Gear Solid 4", system: "PS3", esrb_rating: "M", studio: "Konami") | ||
| # PS4 | ||
| Game.create(name: "Contrast", system: "PS4", esrb_rating: "M", studio: "Compulsion Games") | ||
| Game.create(name: "DiveKick", system: "PS4", esrb_rating: "M", studio: "One True Game Studios") | ||
| Game.create(name: "Super Motherland", system: "PS4", esrb_rating: "M", studio: "XGen Studios") | ||
| Game.create(name: "Warframe", system: "PS4", esrb_rating: "M", studio: "Digital Extremes") | ||
| # GameBoy | ||
| Game.create(name: "Fire Emblem: Awakening", system: "GameBoy", esrb_rating: "M", studio: "Nintendo") | ||
| Game.create(name: "The Legend of Zelda: A Link Between Worlds", system: "GameBoy", esrb_rating: "M", studio: "Nintendo") | ||
| Game.create(name: "Mario Kart 7", system: "GameBoy", esrb_rating: "M", studio: "Nintendo") | ||
| Game.create(name: "Super Mario 3D Land", system: "GameBoy", esrb_rating: "M", studio: "Nintendo") |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| class Game < ActiveRecord::Base | ||
|
|
||
| validates_presence_of :name, :system, :esrb_rating, :studio | ||
|
|
||
| def to_s | ||
| "#{name} - Developed by #{studio}. Rated: #{esrb_rating}" | ||
| end | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,82 @@ | ||
| require 'rubygems' | ||
| require 'bundler/setup' | ||
| require 'io/console' | ||
|
|
||
| require "./db/setup" | ||
| Dir.glob('./models/*').each { |r| require r} | ||
| require "./db/seed" | ||
| require './db/setup' | ||
| Dir.glob('./models/*').each { |r| require r } | ||
| require './db/seed' | ||
|
|
||
| puts "There are #{Show.count} in the database" | ||
| ## | ||
| # Begin the program by asking the user what they would like to do. | ||
| ## | ||
| def start | ||
| puts <<-EOF | ||
| What would you like to do today? | ||
|
|
||
| Network.all.each do |network| | ||
| puts "Shows airing on #{network}" | ||
| network.shows.each do |show| | ||
| puts show | ||
| end | ||
| (1)I'd like to see what shows are playing. | ||
|
|
||
| (2)I'd like to see what games I have. | ||
|
|
||
| EOF | ||
| sel = STDIN.getch.to_i | ||
| case sel | ||
| when 1 | ||
| show_search | ||
| when 2 | ||
| game_search | ||
| end | ||
| end | ||
|
|
||
|
|
||
| def show_search | ||
| days_of_week = %w[Monday Tuesday Wednesday Thursday Friday Saturday Sunday] | ||
|
|
||
| puts "There are #{Show.count} shows in the database\n\n" | ||
|
|
||
| puts 'What day would you like to search?' | ||
| day_selection = gets.strip.capitalize | ||
| ## For the glory of eye candy | ||
| puts "Searching...\n\n" | ||
| sleep 1 | ||
| if day_selection | ||
| results = Show.where(day_of_week: day_selection) | ||
| if results == [] | ||
| puts "There are no shows on #{day_selection}" | ||
| else | ||
| puts "These are the shows that are playing on #{day_selection}" | ||
| results.each do |show| | ||
| puts show | ||
| end | ||
| end | ||
| end | ||
| end | ||
|
|
||
|
|
||
| def game_search | ||
| game_systems = %w[Xbox360 XboxOne PS3 PS4 GameBoy] | ||
|
|
||
| puts "There are #{Game.count} games in the database.\n\n" | ||
|
|
||
| puts "What system do you want to search on?\n\n" | ||
| ## Pull each system out of game_systems and label them by number. | ||
| game_systems.each do |system| | ||
| puts " (#{game_systems.index(system)+1}) #{system}" | ||
| end | ||
| user_selection = STDIN.getch.to_i-1 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is probably pretty hard to read in the future. eg: "why are we doing Recommend moving these bits of functionality to methods that have names that make sense to future-you |
||
| puts "Searching...\n\n" | ||
| sleep 1 | ||
| system_selection = game_systems[user_selection] | ||
| if system_selection | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These nested IF/s are also pretty hard to read. Guideline: if you need nested ifs, move the outer if into a method |
||
| results = Game.where(system: system_selection) | ||
| if results == [] | ||
| puts "There are no games listed for that system." | ||
| else | ||
| puts "These are the games you have for #{system_selection}:\n\n" | ||
| results.each do |game| | ||
| puts game | ||
| end | ||
| end | ||
| end | ||
| end | ||
|
|
||
| start | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice use of the multi-line string!