Skip to content

Instantly share code, notes, and snippets.

View PamBWillenz's full-sized avatar

PamBWillenz

View GitHub Profile
@PamBWillenz
PamBWillenz / crometrics-application.md
Last active July 29, 2017 17:03
CROmetrics Engineering Application

CROmetrics Engineering Application

Thanks for your interest in working with us! To apply:

  • Create a "new gist" (link in github header once you're logged in) with the Raw Text of this .md file (do not fork this gist). Please name your gist a crometrics-application.md so that it's formatted correctly (not a .txt file)
  • Answer the following questions in the spaces provided
  • Send an email to tom@crometrics.com, chris@crometrics.com, and matthew.gossage@crometrics.com that includes:
    • A paragraph that tells us a little about yourself and why you are interested in this job
    • A link to your Gist
  • Your desired hourly rate and general availability
#module AnagramPuzzle
class Anagram
def initialize
@word_list = word_list
end
def word_list
@PamBWillenz
PamBWillenz / Quiz #3.rb
Created July 11, 2016 20:40
A test of object oriented programming - for the Firehose Project
class Bike
attr_accessor :type, :model
def initialize(type, model)
@type = type
@model = model
end
def tour_bike
puts "A #{@type} #{@model} is one of the tour bikes this year."
@PamBWillenz
PamBWillenz / Mapping
Last active August 29, 2015 14:19
Blocks
INSTRUCTIONS
The map method is one of the most common methods you'll call on an array, along with each.
The map method iterates over an array and passes each element to a block, just like each. Unlike each, the return value of the block is put into a new array which is ultimately returned.
Note: The array returned from map is not the original array, so the original array will not be modified:
array = [1,2,3]
@PamBWillenz
PamBWillenz / Good Parents
Last active August 29, 2015 14:19
Advanced Classes Checkpoint
INSTRUCTIONS
Create a Apple class. It should take a single argument on initialization -- a boolean value (true or false) asserting whether or not it is ripe. Apple should define a tasty? instance method that returns "Yes" when ripe and "Not yet" when not.
Below it, create a Fuji class which inherits from Apple and adds two methods:
flavor -- Returns "Sweet" if ripe and "Tart!" if not.
color -- Returns "Yellowish red" if ripe and "Green" if not.
Your class should work like this:
not_ready = Fuji.new(false)
@PamBWillenz
PamBWillenz / Hash Methods
Last active December 17, 2015 23:33
Hashes
INSTRUCTIONS
Create a method named merge_us that expects two arguments and combines them, assuming they're hashes. The Hash class has a method named merge that will be helpful to you.
Create a method named my_keys that takes a hash argument and returns an Array of its keys. The Hash class has a method named keys that will be helpful to you.
Create a method named do_i_have? which expects two arguments. The arguments should represent a Hash and Array of keys. do_i_have? should return true if the Array has all of the keys in the hash, and false if it does not. To create this method, you could start with something like this:
def do_i_have?(hash, array_of_keys)
end
You want to make sure that every key in the hash argument is also contained in the array_of_keys argument. (Remember that hash is expected to be Hash and array_of_keys is expected to be an Array). To compare two objects for equality, you need them to be evaluated as the same object type. That is, you can't explicitly compare a Hash to an Array, but y
@PamBWillenz
PamBWillenz / Each With Index
Last active March 4, 2018 00:04
Loops - Bloc Checkpoint
INSTRUCTIONS
[2,4,6].each_with_index do |element, index|
p "#{element} is at position #{index}"
end
Write a method, add_value_and_index, that takes an array of numbers and returns a new array composed of the value-plus-the-index of each element in the argument array:
add_value_and_index([2,4,6])
#=> 2,5,8
SPECS
@PamBWillenz
PamBWillenz / Calculator Class
Last active August 29, 2015 14:19
Intro To Classes 2 - Bloc Checkpoint
INSTRUCTIONS:
Write a Calculator class that is initialized with two arguments (x and y) and performs basic math operations on them. Your class should have the following methods:
A single class method -- description -- which returns the string "Performs basic mathematical operations".
An add instance method which adds the two instance variables together.
A subtract instance method which subtracts the second variable from the first.
A multiply instance method which multiplies them together.
A divide instance method which divides the first variable by the second.
SPEC
@PamBWillenz
PamBWillenz / Attr Accessor
Last active August 29, 2015 14:18
INTRO TO CLASSES - Bloc Checkpoint
Getter and setter methods are so common that Ruby provides a shortcut to create them. The attr_accessor method creates a getter and setter method based on an argument. You call the attr_accessor with a Symbol argument:
class Square
attr_accessor :size
end
s = Square.new
s.size = 10 # This is the setter
s.size #=> 10 # This is the getter
Notice how we have both the getter and setter methods for size, because we called:
@PamBWillenz
PamBWillenz / Array Definition
Last active August 29, 2015 14:18
Arrays - Code Checkpoint
def new_array(a,b,c,d)
# return an array consisting of the arguments here
end
SPECS
describe "new_array" do
it "creates an array of numbers" do
expect( new_array(1,2,3,4) ).to eq([1,2,3,4])
end
it "creates an array of strings" do
expect( new_array("a", "b", "c", "d") ).to eq(["a", "b", "c", "d"])