This file contains hidden or 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 'nokogiri' | |
require 'sqlite3' | |
require 'open-uri' | |
# def comb_page | |
# page = Nokogiri::HTML(open("http://students.flatironschool.com/students/chrisgonzales.html")) | |
# student_name = page.search("h4").first.text | |
# quote = page.search("h3").first.text | |
# scraped_database = SQLite3::Database.new ":scraped_data:" |
This file contains hidden or 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 'nokogiri' | |
require 'sqlite3' | |
require 'open-uri' | |
# def comb_page | |
# page = Nokogiri::HTML(open("http://students.flatironschool.com/students/chrisgonzales.html")) | |
# student_name = page.search("h4").first.text | |
# quote = page.search("h3").first.text | |
# scraped_database = SQLite3::Database.new ":scraped_data:" |
This file contains hidden or 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
# Great news! You're going to an NBA game! The only catch is that you've been volunteered to keep stats at the game. | |
# Using Nested Hashes, define a game, with two teams, their players, and the players stats: | |
# The game has two teams. | |
# A team has: | |
# A name | |
# Two colors | |
# Each team should have at least 5 players | |
# Each player should have a: |
This file contains hidden or 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 <= 21 && 18 <= temp | |
"I like this temperature" | |
else | |
"This is uncomfortable for me" | |
end | |
end |
This file contains hidden or 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
# Chain at least 5 method calls to an object. Reduce this operation one chain at a time. | |
# Don't just use the methods below, make up your own chain and try to see if you can do something fun with Ruby like in the example. | |
# Example: | |
# puts "start".reverse.slice(0,2).concat("uth").capitalize | |
# # => Truth | |
# Because: |
This file contains hidden or 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 Hashes for the following use-cases. | |
# A movie collection that organizes by genres | |
movies = { | |
"horror" => ["night of the living dead", "exorcist"], | |
"adventure" => ["return of the jedi", "romancing the stone"], | |
"comedy" => ["dumb and dumber", "fargo"] |
This file contains hidden or 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. | |
favorite_foods = ["Chicken tikka Masalla", | |
"Roasted Rabbit", | |
"Fried Ocra", | |
"Chanterelle Mushroom Soup", | |
"Pan Seared Skirt Steak"] | |
# Write a puts which returns your most favorite food out of the array. |
This file contains hidden or 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
# jukebox.rb | |
songs = [ | |
"The Phoenix - 1901", | |
"Tokyo Police Club - Wait Up", | |
"Sufjan Stevens - Too Much", | |
"The Naked and the Famous - Young Blood", | |
"(Far From) Home - Tiga", | |
"The Cults - Abducted", |
This file contains hidden or 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
songs = [ | |
"The Phoenix - 1901", | |
`open http://www.youtube.com/watch?v=HL548cHH3OY` | |
"Tokyo Police Club - Wait Up", | |
`open http://www.youtube.com/watch?v=VARmJlPu6i4` | |
"Sufjan Stevens - Too Much", | |
`open http://www.youtube.com/watch?v=K0g7R3xqdcM` |
This file contains hidden or 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 fizzbuzz(count_up_to) | |
number = 1 | |
for number in 1..count_up_to | |
print "FizZ" if number%3 == 0 | |
print "BuzZ" if number%5 == 0 | |
puts "\n" | |
puts number unless (number%3 == 0) || (number%5 == 0) | |
puts "\n" | |
end | |
end |