Skip to content

Instantly share code, notes, and snippets.

View ashleygwilliams's full-sized avatar

ashley williams ashleygwilliams

  • 10:16 (UTC -05:00)
View GitHub Profile
@ashleygwilliams
ashleygwilliams / gist:5757256
Last active December 18, 2015 08:49
enumerable lab#1: green grocer

##Objectives: Create a checkout method to calculate the total cost of a cart of items and apply discounts and coupons as necessary.

Dr. Steve Bruhle, your green grocer, isn't ready, but you are!

##Skills: any?, all?, none?, each, map/collect

##Instructions: Code generates a random cart of items and a random set of coupons. Implement a method checkout to calculate total cost of a cart of items and apply discounts and coupons as necessary.

@ashleygwilliams
ashleygwilliams / gist:5757253
Last active December 18, 2015 08:49
enumerable lab #3: pokemon

##Objectives:

Implement your own version of any?, all?, and none? to evaluate your pokemon team.

##Skills: any?, all?, none?, yield, blocks

##Instructions: Code contains a set of statements about a randomly generated pokemon team Implement and call your own versions of any?, all? and none? so that the statements are true.

@ashleygwilliams
ashleygwilliams / gist:5757248
Last active December 18, 2015 08:49
enumerable lab #2: decoder

##Objectives: Use String, Hash, Array, and Enumerable methods to decode a string and discover a secret message

INSPIRATION: http://www.youtube.com/watch?v=Wj1d85CLDOQ

##Skills: String.split, Array.each, Hash.each, Hash.sort_by, Range.to_a, Array.reverse, Array.push, Array.join, String.gsub, Array.index

##Instructions: Comments explain steps to manipulate string

i have [["a", "b", "c"],["a", "b", "z"],["d", "e", "f"],["d", "e", "p"]]
ok i need to buil {a=>??,d=>??}
THEN i need to build {a=>b, d=>e}
THEN i need to build {a=>{b=>??},d=>{e=>??}}
THEN i need to build {a=>{b=>[]]},d=>{e=>[]]}}
** maybe make [c,z] and [f,p]
THEN i need to build {a=>{b=>[c]]},d=>{e=>[f]]}}
@ashleygwilliams
ashleygwilliams / woodchuck.rb
Last active December 18, 2015 02:29
how much wood would a woodchuck chuck? a lesson in the difference between class and instance variables and methods.
class Woodchuck
attr_accessor :chuck_count
@@woodchuck_count = 0
def initialize
@chuck_count = 0
@@woodchuck_count += 1
end
@ashleygwilliams
ashleygwilliams / gist:5682375
Last active December 17, 2015 22:29
practicing instance variables/methods and class variable/methods
#CLASS/INSTANCE METHODS AND VARIABLES PRACTICE:
#
#1. create a class called Project
class Project
#3. make the instance variables accessible by dot notation EXCEPT for date updated
attr_accessor :title, :description, :role, :date_created
#1. create a class variable called count
@@count = 0
@ashleygwilliams
ashleygwilliams / bethecompiler.rb
Created May 30, 2013 23:05
go through this program and explain what the compiler does line by line. give line numbers.
# instance methods -
# def methodName
# end
# * only belong to objects
# * access them via dot notation
# * can use instance variables
#
# instance variables -
# def initialize
# @variable = value
@ashleygwilliams
ashleygwilliams / gist:5667062
Last active December 17, 2015 20:19
Notes from class, 28 May 2013
Classes are blueprints. Objects are known as 'instances' of these classes.
Classes are where we define all variables and methods.
Instance variables (@var_name) and instance methods (def method_name) belong only to objects and are accessed using dot notation (Object.name) on an object made using 'Class.new'.
Class variables (var_name)
@ashleygwilliams
ashleygwilliams / gist:5551908
Created May 10, 2013 01:53
Here's the code from Tom's talk! If you have more questions, you should tweet @ThomasLevine
#!/usr/bin/env ruby
require 'open-uri'
require 'nokogiri'
download = open("http://www.dol.gov/olms/regs/compliance/cba/Cba_CaCn.htm")
html = Nokogiri::HTML(download)
tables = html.search("table")
table = tables[1]