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 'rack' | |
class StevenApp | |
def call(env) | |
p env['PATH_INFO'] | |
p env['HTTP_ACCEPT'] | |
[200, {'Content-Type' => 'text/html'}, | |
['<h1>Hello <a style="color: pink" href="http://students.flatironschool.com/students/stevenbrooks.html">Steven</a></h1>']] |
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 reverse_each_word(sentence) | |
sentence.split.collect { |word| word.reverse }.join(" ") | |
end | |
puts reverse_each_word("Hello world") |
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
# Testing / Assertion | |
# Define a method that takes two values and compares them, printing pass or fail | |
class Person | |
attr_accessor :name, :birthday :age | |
def name(string) | |
@name = string | |
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
# Columns to add to Students table: | |
# Name | |
# Profile Pic | |
# Social media links/ Twitter, LinkedIn, GitHub, Blog(RSS) | |
# Quote | |
# About/ Bio, Education, Work | |
# Coder Cred / Treehouse, Codeschool, Coderwal .reject(Github) | |
require 'nokogiri' | |
require 'open-uri' |
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
ITEMS = [ {"AVOCADO" => {:price => 3.00, :clearance => true}}, | |
{"KALE" => {:price => 3.00,:clearance => false}}, | |
{"BLACK_BEANS" => {:price => 2.50,:clearance => false}}, | |
{"ALMONDS" => {:price => 9.00, :clearance => false}}, | |
{"TEMPEH" => {:price => 3.00,:clearance => true}}, | |
{"CHEESE" => {:price => 6.50,:clearance => false}}, | |
{"BEER" => {:price => 13.00, :clearance => false}}, | |
{"PEANUTBUTTER" => {:price => 3.00,:clearance => true}}, | |
{"BEETS" => {:price => 2.50,:clearance => false}} | |
] |
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
$basketball_game = | |
{ | |
:team_1 => | |
{ | |
:team_name => "Nets", | |
:color => ["black", "grey"], | |
:player_1 => | |
{ | |
:name => "Brooke Lopez", | |
:jersey => 11, |
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
# Temperature bot is American but takes Celsius temperatures. | |
# | |
def temperature_bot(temp) | |
case temp | |
when temp = 18..22 | |
"I like this temperature" | |
else | |
"This is uncomfortable for me" | |
end | |
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
puts "hello".upcase | |
puts "hello".upcase.downcase | |
puts "hello".upcase.downcase.capitalize | |
puts "hello".upcase.downcase.capitalize.concat(" world!") | |
puts "hello".upcase.downcase.capitalize.concat(" world!").upcase |
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
movies_by_genre = { 'rocky' => 'love', 'tropic thunder' => 'comedy', 'star wars' => 'unknown'} | |
recipes = | |
{ | |
:"steak" => ['steak', 'salt', 'pepper'], | |
:"salad" => ['lettus', 'dressing'] | |
} | |
users = | |
{ |
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
#Construct an array with your favorite foods. It should have at least 5 elements. | |
array = ['Lobster', 'Bacon', 'Steak', 'Grilled Chicken', 'Ice Cream'] | |
#Write a puts which returns your most favorite food out of the array. | |
puts array[0] | |
#Construct an array with the colors of the rainbow (ROYGBIV) |