This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import time | |
require 'active_support/core_ext/integer/inflections' | |
#declare fruits and clues, choose answer | |
@ary = [["banana", "It's yellow"], ["orange", "It's a color, too"], ["grape", "From vine to wine"], ["apple", "Johnny loved to plant these"], ["pear", "Rhymes with bear"], ["mango", "Hey man, go"], ["lemon", "Very very sour"], ["date", "Very gulf coast and socially awkward"]] | |
def choose_an_answer | |
@answer = @ary[rand(7)][0] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_users_name | |
puts "Hi! Welcome to the psychic personality machine." | |
puts "First, tell me your name: " | |
@name = gets.chomp | |
@name.capitalize! | |
@first_name = @name | |
puts "\n\nAwesome #{@name}, nice to meet you!" | |
puts "Let's get started." | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create racetrack | |
class RaceTrack | |
attr_reader :horses_racing, :length, :names, :now_playing, :winner | |
def initialize | |
@length = 75 | |
@horses_racing = [] | |
#let_them_race | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Build track | |
# Begin the game | |
# Assign user a horse | |
# Create competition | |
#Horse | |
# Display movement | |
# Be responsible for movement | |
# Updates horse's position |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class World | |
attr_reader :cells, :cells_with_neighbors, :cells_that_should_live, :cells_that_should_die | |
# [ | |
# [cell cell cell], | |
# [cell cell cell], | |
# [cell cell cell] | |
# ] | |
def initialize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rspec' | |
class Match | |
attr_reader :players, :winner | |
def initialize | |
@players = [TennisPlayer.new] * 2 | |
end | |
def winner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Doctor < ActiveRecord::Base | |
has_many :patients | |
end | |
class Patient < ActiveRecord::Base | |
belongs_to :doctor | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Let's say you have a database containing two tables, doctors and patients. | |
This means you have two models, Doctor and Patient. | |
We want to find all doctors who have female patients. | |
Our relationship (one to many) is based on the doctor_id being a foreign key in the patients table. | |
To query through Rails we use: | |
Doctor.joins(:patients).where('patients.gender = ?', 'female') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Photo < ActiveRecord::Base | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
User visits site | |
User logins in or registers | |
Login -> input email, password -> redirect to home | |
Register -> provide user details, upload avatar photo -> submit -> redirect to login | |
User to home page | |
User edits settings | |
Clicks settings -> edit profile -> provides updated information -> submit -> back to home | |
-> clicks delete profile -> inputs password -> submit -> redirect to login |
OlderNewer