Skip to content

Instantly share code, notes, and snippets.

View reneedv's full-sized avatar

Renée Hendricksen reneedv

View GitHub Profile
@reneedv
reneedv / fizz_buzz.rb
Created June 12, 2012 19:34 — forked from quardox/fizz_buzz.rb
FizzBuzz Homework 1
# Write a Ruby script that prints the numbers from 1-100,
# replacing every multiple of 3 with the word Fizz,
# replacing every multiple of 5 with the word Buzz,
# and replacing every multiple of both with the word FizzBuzz
#
# My idea was to create an array of 1-100, then convert that to a string so I could use successive gsubs to replace the multiples with the correct words. When I try to run it I get "undefined method 'gsub' for #<Array>. I've discovered I'm a lot better at editing/adding to things that already exist than trying to set up a script from scratch. Not sure if I'm even on the right track here and I could definitely use your input. Thanks!
array = Array (1..100)
puts array
numbers = array.to_s
@reneedv
reneedv / fizz_buzz.rb
Created June 11, 2012 19:28
FizzBuzz Homework 1
# Write a Ruby script that prints the numbers from 1-100,
# replacing every multiple of 3 with the word Fizz,
# replacing every multiple of 5 with the word Buzz,
# and replacing every multiple of both with the word FizzBuzz
#
# Extra Credit: your script does not use if statements (or unless!), while loops, or switch statements
#
# Your Output should look like this:
renee$ ruby fizz_buzz.rb
1
@reneedv
reneedv / wine_glass.rb
Created June 11, 2012 19:22
Wine Glass Homework 1
# Make the existing tests pass.
# Add 2 more tests and methods for:
## 1. Another print method for material, volume, and stem_length all together
## 2. A method that calculates and returns the percent of the glass that is full when you pass in the
### volume of liquid in the glass.
### This calculation is: (volume_passed_to_method / volume_of_wine_glass) * 100
class WineGlass
attr_accessor :material, :volume, :stem_length
def pretty_print_material
def test_wg_pretty_prints_stem_length_and_volume
assert_equal "This wine glass is cool. It has a stem length of 5 and a volume of 6500ml", @wg.pretty_print_stuff
end
@reneedv
reneedv / Rails New Development and Deploy
Created June 1, 2012 03:32
Making and Deploying a new Rails web application using Postgresql
#1 First open your terminal program and type cd to go to your home directory:
cd
#2 To create a new rails application called q_man using postgresql:
rails new q_man -d postgresql
#3 Enter the application directory:
cd q_man
#4 Start the local webserver
rails s
@reneedv
reneedv / table.rb
Created May 31, 2012 20:02 — forked from brookr/table.rb
A basic Table class
# Assignment: Fill in this Table class so the tests pass!
# Exercise Details:
#- Make a Table object class
#- Define at least 5 properties of a Table (legs, material, items_on_it, etc…)
#- Define an initialize method that sets one or more of the attributes when you call Table.new
#- Define a pretty_print method that prints out some useful information about your table
#- Email us a link to your code in a Gist
# Extra Credit:
@reneedv
reneedv / RSR Exercise 1
Created May 31, 2012 19:54
RSR Exercise 1
Exercise
- Make a Table object class
- Define at least 5 properties of a Table (legs, material, items_on_it, etc…)
- Define an initialize method that sets one or more of the attributes when you call Table.new
- Define a pretty_print method that prints out some useful information about your table
- Email us a link to your code in a Gist
Extra Credit:
- Make tests for your Table class
- Try the Exercises in the Gist for the Book class
@reneedv
reneedv / book.rb
Created May 31, 2012 15:22
Book Exersice File
# Exercises - write two methods in the book class that make the failing tests pass
# Extra Credit - refactor the way page_count is handled so it is more DRY
# Extra Extra Credit - add a humanize method to the String class so you can take a string like this:
# 'page_count' and turn it into this 'page count'
# Be sure to add tests for your extra credit!!
class Book
attr_accessor :title, :author, :page_count, :pages