Skip to content

Instantly share code, notes, and snippets.

@jessieay
jessieay / Event Manager
Created June 20, 2012 23:55
Event manager ruby project created in week 2 at DBC
# Dependencies
require "csv"
require 'sunlight'
# Class Definition
class EventManager
INVALID_ZIPCODE = "00000"
INVALID_PHONE_NUMBER = "0000000000"
Sunlight::Base.api_key = "e179a6973728c4dd3fb1204283aaccb5"
def initialize(filename)
@jessieay
jessieay / RPS contest
Created June 19, 2012 00:23
Tournament of RPS contest
def game(match)
if match[0][1].upcase =="R"
if match[1][1].upcase == "P"
match[1]
elsif match[1][1].upcase == "S"
match[0]
else
"It's a Tie!"
end
@jessieay
jessieay / New-inject
Created June 18, 2012 22:17
Redefinition of inject
class Array
def new_inject
result = 0
(1..self.length).each do |i|
result = yield(result, self[i-1])
end
result
@jessieay
jessieay / New Collect
Created June 18, 2012 01:07
Practicing procs, still not sure why this works
class Array
def new_collect
self.collect do |n|
yield n
end
end
end
RSPEC:
@jessieay
jessieay / RPN FTW
Created June 17, 2012 17:23
RPN that passes rspec
class RPNCalculator
attr_accessor :calculator, :result, :subtotal, :mini_array
def initialize
@calculator = []
@mini_array = []
@result = 0
@subtotal = 0
end
@jessieay
jessieay / RPN - almost complete
Created June 17, 2012 06:26
RPN w one test not passing
class RPNCalculator
attr_accessor :calculator, :result, :subtotal, :mini_array
def initialize
@calculator = []
@mini_array = []
@result = 0
@subtotal = 0
end
@jessieay
jessieay / RPN new
Created June 16, 2012 04:59
RPN w one test passting
class RPNCalculator
attr_accessor :calculator, :result
def initialize
@calculator = []
@result = 0
end
def push(arg)
@jessieay
jessieay / RPN in progress
Created June 16, 2012 04:47
RPN in progress
class RPN
attr_accessor :calculator
def initialize
@calculator = []
end
def push(arg)
@jessieay
jessieay / Dict - o - nary
Created June 16, 2012 00:00
Dictionaryyyyyy
class Dictionary
attr_accessor :this_dictionary
def initialize
this_dictionary = {}
@this_dictionary = this_dictionary
end
def entries
@jessieay
jessieay / My First Instance Variables
Created June 15, 2012 16:51
Baby's first instance variables
def Calculator
def add(num1,num2)
@num1= num1
@num2 = num2
output("sum", num1 + num2)
end
def subtract(num1,num2)
@num1= num1