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 Student | |
attr_accessor :name, :twitter, :linkedin, :facebook, :website | |
attr_reader :id | |
@@students = [] | |
def initialize | |
@@students << self | |
@id = @@students.count | |
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
class Jukebox | |
attr_accessor :songs, :desire, :current_song #:song_hash | |
def initialize(songs) | |
@songs = songs | |
#@song_hash = {} | |
help | |
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
"Which SQL command selects all the columns from the sable?" | |
SELECT * | |
SELECT all | |
SELECT rows | |
SELECT every_one_of_them | |
"Which SQL command is used to sort the result-set?" | |
SORT | |
ARRANGE | |
SORT_BY |
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
######################## | |
# NYC PIGEON ORGANIZER # | |
######################## | |
# Start with the following collected data on NYC pigeons. | |
pigeon_data = { | |
:color => { | |
:purple => ["Theo", "Peter Jr.", "Lucky"], | |
:grey => ["Theo", "Peter Jr.", "Ms .K"], |
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
game = { | |
:the_lakers => { | |
:name => "The Lakers", | |
:colors => ["purple","gold"], | |
:players => { | |
:daniel_mckendrick => { | |
:stats => { | |
:points => 25, | |
:rebounds => 5, | |
:assists => 3, |
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 normalize_phone_number(str) | |
parsed_str = str.gsub(/[^0-9]/, "") | |
return str if parsed_str.length != 10 | |
parsed_str.insert(0, "(") | |
parsed_str.insert(4, ") ") | |
parsed_str.insert(9, "-") | |
return parsed_str |
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
# You're hosting a conference and need to print badges for the speakers. Each | |
# badge should say: "Hello, my name is _____." | |
# **Write a method that will create and return this message, given a person's | |
# **name.** | |
def badge(name) | |
"Hello my name is #{name}" | |
end | |
#badge("Trevor") |
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 go back to the exercise where we determined what is and isn't a vowel. | |
# With ruby, there's always more than one way to do something and get the same | |
# result. | |
# Assuming vowels `a,e,i,o,u`: | |
# 1. Write a method that returns whether a given letter is a vowel, using `if` | |
# and `elsif` | |
def is_vowel_one?(letter) |
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 my_each(array) | |
i = 0 | |
while i < array.length do | |
yield(array[i]) | |
i += 1 | |
end | |
end | |
my_each(["boy",7,true,"awesome_sauce","YES"]) { |x| puts x} |
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
#From [rubeque](http://rubeque.com/problems/temperature-robot) | |
#Temperature bot is comfortable when it's room temperature (18-21C). Help him out by completing the method below: | |
#Temperature bot is American but takes Celsius temperatures. | |
def temperature_bot(temp) | |
if temp >= 18 && temp <= 21 | |
puts "I like this temperature" |