Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" >
<meta charset="UTF-8" />
<meta name="viewport" content ="width=device-width, minimum-scale=1.0, initial-scale=1.0">
<title>The Flatiron School</title>
<link rel='stylesheet' href="../css/font-awesome.css" type='text/css' media='screen' />
<link rel='stylesheet' id='google_merriweather-css' href='http://fonts.googleapis.com/css?family=Merriweather:400,700&ver=3.5' type='text/css' media='all' />
<link rel='stylesheet' href="../css/style.css" type='text/css' media='all' />
@sarony
sarony / triangle.rb
Last active December 25, 2015 02:19
class TriangleError < Exception
end
class Triangle
def initialize(side1, side2, side3)
@side1=side1
@side2=side2
@side3=side3
triangle?
require 'simplecov'
SimpleCov.start
require 'json'
require 'rspec'
require_relative './jukebox.rb'
require_relative './song.rb'
describe Song do

##RSpec Code Coverage Lab

How do we know we have enough tests, and that our tests cover all of our code?

Enter simplecov! simplecov is a tool that will measure your test run against the code paths in your code files and see if you're exercising them all. "Code Paths" includes method calls, conditional statements, loops, and anything that branches program flow.

This is important because you want to be able to know that every decision your program makes is being tested, no matter what.

Assignment

class School
attr_accessor :roster
def initialize(name)
@name=name
@roster={}
end
def add_student(name, grade)
@roster[grade]||=[]
a = [1,2,3,4]
b = []
c = []
all = [a, b, c]
def aab_move(a, b, c)
b.unshift(a.first)
a.shift
c.unshift(a.first)
# Hashketball Nests
#
# 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.
game = {
:team1=> {
holiday_supplies = {
:winter => {
:christmas => ["Lights", "Wreath"],
:new_years => ["Party Hats"]
},
:summer => {
:forth_of_july => ["Fireworks", "BBQ"]
},
:fall => {
:thanksgiving => ["Turkey"]
def reverse_each_word(sentence)
# do your magic here
words=sentence.split(" ")
reversed=words.collect { |word| word.reverse }
reversed.join(" ")
end
reverse_each_word("This is cool and stuff.")
# A movie collection that organizes by genres
# Recipes with ingredients
# User profiles where each user has a list of favorite colors along with 3 personal essays, essay_1, essay_2, essay_3
movie_collection = {
:action => ["Bourne", "Salt", "Terminator"],
:comedy => ["Madea", "Zoolander", "Bridesmaids"],
:horror => ["28", "Saw", "The Hills Have Eyes"]
}