Skip to content
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.

Final Project #131

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d9d1b19
Week 1 homework is complete, still need to finish answering questions
jonfaulkenberry Oct 9, 2013
f348ef5
Fixed rspec file
jonfaulkenberry Oct 9, 2013
c2b96b1
Finished week 1 homework
Oct 10, 2013
d807a50
week 1 homework answers
reneedv Oct 16, 2013
606fbc2
Merge branch 'master' of https://github.com/UWE-Ruby/RubyFall2013
jonfaulkenberry Oct 16, 2013
91325c3
Added notes
jonfaulkenberry Oct 16, 2013
8b02060
Merge branch 'master' of https://github.com/UWE-Ruby/RubyFall2013
jonfaulkenberry Oct 16, 2013
2cafa58
week2 stuff
jonfaulkenberry Oct 17, 2013
cb45f33
Merge branch 'master' of https://github.com/jonfaulkenberry/RubyFall2013
jonfaulkenberry Oct 17, 2013
f6950ea
all week2 tests passed
jonfaulkenberry Oct 17, 2013
eb3109c
finished week2 homework
jonfaulkenberry Oct 22, 2013
aaf450e
finished week2 homework
jonfaulkenberry Oct 22, 2013
02ccc7d
week 2 homework answers
reneedv Oct 23, 2013
4a19288
Merge branch 'master' of https://github.com/UWE-Ruby/RubyFall2013
jonfaulkenberry Oct 23, 2013
db222ee
adding week3 stuff
jonfaulkenberry Oct 23, 2013
bf5f43c
week3 tests passing
jonfaulkenberry Oct 24, 2013
19d4e50
week3 done
jonfaulkenberry Oct 29, 2013
c5ff825
Adding some uncommitted files
jonfaulkenberry Oct 30, 2013
761cef0
Adding some uncommitted files
jonfaulkenberry Oct 30, 2013
d1337e6
Merge branch 'master' of https://github.com/UWE-Ruby/RubyFall2013
jonfaulkenberry Oct 30, 2013
a6727ff
Adding week4 stuff
jonfaulkenberry Oct 30, 2013
7236498
Finished week4 hw
jonfaulkenberry Nov 5, 2013
ef5ff6c
Merge branch 'master' of https://github.com/UWE-Ruby/RubyFall2013
jonfaulkenberry Nov 7, 2013
f7fe0b9
Merge branch 'master' of https://github.com/UWE-Ruby/RubyFall2013
jonfaulkenberry Nov 7, 2013
dd39e30
Merge branch 'master' of https://github.com/jonfaulkenberry/RubyFall2013
jonfaulkenberry Nov 8, 2013
12eed61
Merge branch 'master' of https://github.com/UWE-Ruby/RubyFall2013
jonfaulkenberry Nov 13, 2013
29cf6f0
Merge branch 'master' of https://github.com/UWE-Ruby/RubyFall2013
jonfaulkenberry Nov 25, 2013
8b86f05
Finished week7 homework questions
jonfaulkenberry Nov 26, 2013
bd14e12
Merge branch 'master' of https://github.com/jonfaulkenberry/RubyFall2013
jonfaulkenberry Nov 26, 2013
68936f9
Merge branch 'master' of https://github.com/UWE-Ruby/RubyFall2013
jonfaulkenberry Nov 26, 2013
61355c8
Merge branch 'master' of https://github.com/jonfaulkenberry/RubyFall2013
jonfaulkenberry Nov 26, 2013
91bca5c
Finished week7 homework
jonfaulkenberry Nov 26, 2013
32bf28d
Merge branch 'master' of https://github.com/UWE-Ruby/RubyFall2013
jonfaulkenberry Nov 27, 2013
be3b1d5
Working on TicTacToe
jonfaulkenberry Nov 27, 2013
ecb940b
Merge branch 'master' of https://github.com/UWE-Ruby/RubyFall2013
jonfaulkenberry Dec 10, 2013
439eb45
Finished TicTacToe
jonfaulkenberry Dec 10, 2013
64fdd81
Merge branch 'master' of https://github.com/jonfaulkenberry/RubyFall2013
jonfaulkenberry Dec 10, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions notes/week2_notes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
"git remote -v" lists all repositories that are connected

you can pass the git clone any .git directory you want

git remote add other /Users/jon/test_git

git remote add class_repo https://github.com/UWE-Ruby/RubyFall2013.git

git pull origin master

upstream

git branch answers

git checkout answers

git log --oneline

-----

JRuby - converts ruby code into java code

MRI == CRuby

respond_to?
what messages does the object respond to?
* method calls or properties

rather than checking the type, check to see if it
responds to the message you are sending it

^this is the principle of duck typing

sudo gem install grb

simplies working with remote branches

"Hello world".respond_to? "+"

.inspect

%q(hello world)
%Q(hello world)

ruby inherits smalltalk's thinking in that
it treats methods as messages that are responded to.

a # sign in front of a method in the docs indicates it is an instance
:: in the docs indicates a class method

"hello".send("size")
"hello".size

"hello".send("+", "world")

my_name.chop!

.object_id

my_name = "Hello"
other_name = my_name
my_name = "Hello World"
puts other_name
# prints "Hello" and NOT "Hello World"
# because other_name is pointing to the
# original "Hello" string literal object









101 changes: 101 additions & 0 deletions notes/week3_notes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
To implement Enumerable just make a method called each, which
usually calls each on something else...

@ sign before a variable makes it an instance variable

looks for a method a called title= when you see myClass.title = "Hello"

def title= t
@title = t
end

attr_accessor :property
attr_reader :property
attr_writer :property

self. before a method name make its a class level method -- like a static method

class variables are defined with two @@ signs

@inst_var
@@class_var

three ways of declaring a class level method:

myClass.myMethod() <--- you have to change the name of the method when you change the name of the class
self.myMethod() <--you dont have to do the above

self <<
def myMethod()
end

^^in the above case you are adding a method to the self obj, weird syntax

::new = class level
#new = instance level

default values:

def initialize title = "Not Set"
@title = title
end

||= is "or equals"

@@book_count ||= 0

"if @@book_count is not set, set to 0, otherwise return @@book_count"

ruby does not use ++

use i += 3


arrays and hashes

.first and .last

you can access from the end of the array like myArray[-2]

.select { }

.map and .collect

a.map!{ }

what does the bang do? it does it in-place (aka works on the original object, not a copy)

on an array

h.each do |k, v| end

hash.keys and h.values

myArray.include?(1)
myHash.has_key?(:hello => "Hello")

h[:hello]
h["hello"]

read about symbols

.count

.each vs .map

.each returns the original array passed to it
.map returns the new

.inject and .reduce -- mean the same thing

$monsters.inject(0){ |legs, m| legs += m[:legs] }

0 is the start value, in this case, i can actually leave the start value out,
if you leave it out it tags the first thing


legs is a reference to the running total

dangers.inject(Hash.new(0)){ |hist, danger| hist[danger] += 1 }.

semicolon in irb is a pretend line break
80 changes: 80 additions & 0 deletions notes/week4_notes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
-----------------
notes from week4
-----------------
require "#{File.dirname(__FILE__)}/worker"
you can say require './named_thing.rb'

this will require a file called worker in the same directory
as the file that is being run

# summing numbers with inject
input.inject(0, :+)

# this will sum
# start with 0 and apply this method to each method and the result

# multiplying with
splat args -- (*args)

# you can use flatten to Returns a new array that is a one-dimensional flattening of self (recursively).
# That is, for every element that is an array, extract its elements into the new array.
# The optional level argument determines the level of recursion to flatten.

def fac n
product = 1
1.upto(n){ |i| product *= 1 }
product
end

recursive functions

statement modifiers -- see below

def fac 1
return 1 if n==0 # one of the only times you are going to call return
n * fac(n-1)
end

money gem

BigDecimal class

to_s and to_sym methods

.cover?

(2..200000).cover? 6

does this range include the value 6?

.. is inclusive

... is inclusive

1..5 is 1 through 5 and 1...5 is 1 through 4

('a'..'z').cover? 'B' => false

def <==> (other)
@value <==> other.value
end

The Comparable module

block_given? --- was there a block given?

you can pass a bloc kto any method in ruby, whether or not it does anything with it

passing parameters to block

yield(paramA, paramB)

call(x)

when you use the syntax &myBlock you are turning it into a lambda by giving it a name

def test hello, world, &my_code
my_code.call
end

test "bonjour", "world", {puts "hi"}
1 change: 1 addition & 0 deletions week1/class_materials/.rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--format nested --color
12 changes: 12 additions & 0 deletions week1/class_materials/name_printer_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
describe "NamePrinter Application" do

context "When Renee is logged in" do
it "should say Renee" do
"Renee".should eq "Renee"
end
end

context "Wen Renee is logged out" do
end

end
21 changes: 15 additions & 6 deletions week1/exercises/rspec_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,12 @@

# When this example fails,
# it will show "expected" as 2, and "actual" as 1
1.should eq 2
1.should_not eq 2

end

it "supports placeholder examples that lack code (like this one)"
it "supports placeholder examples that lack code (like this one)" do
end

it "requires that examples use expectations (like #should) to work properly" do

Expand Down Expand Up @@ -77,15 +78,23 @@
# Fix the Failing Test
# Order of Operations is Please Excuse My Dear Aunt Sally:
# Parentheses, Exponents, Multiplication, Division, Addition, Subtraction
(1+2-5*6/2).should eq -13
(1+2-5*6/2).should eq -12
end

it "should count the characters in your name" do
pending
"Jonathan".should have(8).characters
"Jon".should_not have(4).characters
end

it "should check basic math"
it "should check basic math" do
(3 % 2).should eq 1
(33 * 3).should eq 99
end

it "should check basic spelling"
it "should check basic spelling" do
"Jonathan".should_not include "Z"
"Jonathan".should include "Jon"
end

end

Expand Down
23 changes: 23 additions & 0 deletions week1/homework/questions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,36 @@ Chapter 3 Classes, Objects, and Variables
p.86-90 Strings (Strings section in Chapter 6 Standard Types)

1. What is an object?
An object is a representation in memory of a specific concept or thing that the Ruby interpreter knows about.

- An object is an instance of a class and is an entity that has properties and behaviors; represents data.

2. What is a variable?
A variable is a name for a location in memory. It can contain, or point to, any type of object.

- A variable is a reference to an object (labeled container)

3. What is the difference between an object and a class?
An object is an instance of a class, or a specific thing of that class's type in memory. The class is the specifics that are common to all things of that type. The classification of a concept or a thing is a class. A specific thing or concept of a class's type in memory is an object. For example: All books have titles (Class). This book's title is "Harry Potter and the Goblet of Fire" (Object).

- A class is a blueprint for an object. The class is the cookie cutter, objects are the cookies.

4. What is a String?
A string is how Ruby understands text. It is a collection of characters (Bytes), and can be created by making an instance of the String class (String.new) or as a string literal ("",'', %Q[]).

- An object that holds a collection of characters and provides methods for manipulating these characters.

5. What are three messages that I can send to a string object? Hint: think methods
chomp! - removes newline characters, or the specified characters, from the end of a string
strip! - removes leading or trailing whitespace from a string
split - returns an array of strings made up of the original string separated on whitespace or the specified characters or regexp

- .concat, .upcase, .chomp

6. What are two ways of defining a String literal? Bonus: What is the difference between the two?
<<<<<<< HEAD

- double and single quotes. double quotes allow variable inerpolation e.g. "#{foobar}"
=======
Single quotes ex: '' and Double quotes ex: "". The single quotes allow for 2 escape characters: \' and \\ . The double quoted string literal allows for many different escaped special characters (like \n is a line break) and allows for string interpolation, or the injection of evaluated Ruby code into the string ex: "Hello #{my_name}". The single quoted string takes up much less memory than a double quoted string with interpolation. Without interpolation, both are about the same.
>>>>>>> 02ccc7d94fdfc30a6d2d7e93c8bee3f07a3da618
23 changes: 18 additions & 5 deletions week1/homework/strings_and_rspec_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,28 @@
before(:all) do
@my_string = "Renée is a fun teacher. Ruby is a really cool programming language"
end
it "should be able to count the charaters"
<<<<<<< HEAD

it "should be able to count the charaters" do
@my_string.count("R").should eq 2
end

=======
it "should be able to count the characters" do
@my_string.should have(@my_string.size).characters
end
>>>>>>> 02ccc7d94fdfc30a6d2d7e93c8bee3f07a3da618
it "should be able to split on the . charater" do
pending
result = #do something with @my_string here
result = @my_string.split('.')
result.should have(2).items
end

it "should be able to give the encoding of the string" do
pending 'helpful hint: should eq (Encoding.find("UTF-8"))'
@my_string.encoding.should eq (Encoding.find("UTF-8"))
end

it "should be equal the upper case version" do
@my_string.upcase.should eq "RENéE IS A FUN TEACHER. RUBY IS A REALLY COOL PROGRAMMING LANGUAGE"
end
end
end

Loading