diff --git a/config/database.yml.sample b/config/database.yml.sample deleted file mode 100644 index 44360d7..0000000 --- a/config/database.yml.sample +++ /dev/null @@ -1,6 +0,0 @@ -host: 'localhost' -adapter: 'postgresql' -database: 'watchman' -username: XXXXXXX -encoding: 'utf8' -pool: 5 diff --git a/db/migrate/201212030900_create_modes.rb b/db/migrate/201212030900_create_modes.rb new file mode 100644 index 0000000..4424a2b --- /dev/null +++ b/db/migrate/201212030900_create_modes.rb @@ -0,0 +1,9 @@ +class CreateModes < ActiveRecord::Migration + def change + create_table :modes do |t| + t.string :name + t.string :parent + t.string :steps + end + end +end \ No newline at end of file diff --git a/db/seed.rb b/db/seed.rb index 3c028ff..aa91104 100644 --- a/db/seed.rb +++ b/db/seed.rb @@ -1,7 +1,18 @@ # Cleaning Out Network.delete_all Show.delete_all +Mode.delete_all amc = Network.create(name: "AMC") nbc = Network.create(name: "NBC") +abc = Network.create(name: "ABC") +pbs = Network.create(name: "PBS") 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: "Modern Family", day_of_week: "Wednesday", hour_of_day: 21, network: abc) +Show.create(name: "Downton Abbey", day_of_week: "Sunday", hour_of_day: 21, network: pbs) +Mode.create(name: "Ionian", parent: "Major", steps: "1 2 3 4 5 6 7") +Mode.create(name: "Dorian", parent: "Major", steps: "1 2 b3 4 5 6 b7") +Mode.create(name: "Phrygian", parent: "Major", steps: "1 b2 b3 4 5 b6 b7") +Mode.create(name: "Lydian", parent: "Major", steps: "1 2 3 #4 5 6 7") +Mode.create(name: "Lydian Augmented", parent: "Melodic Minor", steps: "1 2 3 #4 #5 6 7") +Mode.create(name: "Super Locrian", parent: "Melodic Minor", steps: "1 b2 b3 b4 b5 b6 b7") \ No newline at end of file diff --git a/models/mode.rb b/models/mode.rb new file mode 100644 index 0000000..5b757de --- /dev/null +++ b/models/mode.rb @@ -0,0 +1,7 @@ +class Mode < ActiveRecord::Base + + def to_s + name + end + +end \ No newline at end of file diff --git a/watchman.rb b/watchman.rb index ebe9be4..714567e 100644 --- a/watchman.rb +++ b/watchman.rb @@ -5,7 +5,7 @@ Dir.glob('./models/*').each { |r| require r} require "./db/seed" -puts "There are #{Show.count} in the database" +puts "There are #{Show.count} in the database:" Network.all.each do |network| puts "Shows airing on #{network}" @@ -13,3 +13,35 @@ puts show end end + + puts "\nWhat day do you want to watch shows?" + user_day = gets.chomp() + + shows_by_day = Show.where(day_of_week: user_day.capitalize) + + if shows_by_day.size == 0 + puts "\nSorry, no shows that day!" + else + puts "\nThere is #{shows_by_day.count} show on #{user_day.capitalize}:" if shows_by_day.size == 1 + puts "\nThere are #{shows_by_day.count} shows on #{user_day.capitalize}:" if shows_by_day.size > 1 + shows_by_day.each do |show_day| + puts show_day + end + end + + puts "\nThe are #{Mode.count} scales in the database:" + + Mode.all.each do |mode| + puts mode + end + + puts "\nWhich mode would you like to learn more about?" + user_mode = gets.chomp() + + current_mode = Mode.where(name: user_mode.titleize).first + + if current_mode == nil + puts "\nSorry, no mode by that name!" + else + puts "\nThe scale steps of #{current_mode.name} are #{current_mode.steps}. It is a mode of the #{current_mode.parent} scale.\n" + end