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

MOHR - FINAL #177

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
017cef8
Changes to class exercises
kellimohr Oct 13, 2012
5552f60
Homework changes
kellimohr Oct 16, 2012
fd40561
Merge branch 'master' of git://github.com/UWE-Ruby/RubyFall2012
kellimohr Oct 16, 2012
ef4eed8
Homework Answers
kellimohr Oct 16, 2012
1e95147
Completed homework for rspec tests
kellimohr Oct 16, 2012
ab56f29
merge changes
kellimohr Oct 17, 2012
d991c00
Exercise Updates
kellimohr Oct 21, 2012
5c696ed
merge conflicts
kellimohr Oct 21, 2012
dca2603
Finished Homework for week 2
kellimohr Oct 21, 2012
d1518c9
merge address changes
kellimohr Oct 21, 2012
84c6312
Syncing Homework with uwe-ruby master
kellimohr Oct 24, 2012
7b7f643
Finished programming homework for week 3
kellimohr Oct 24, 2012
cb6353e
Finished homework questions.
kellimohr Oct 30, 2012
48ce146
Merge changes
kellimohr Oct 31, 2012
8b56cab
In class exercises
kellimohr Nov 2, 2012
d1633a9
Merge branch 'master' of git://github.com/UWE-Ruby/RubyFall2012
kellimohr Nov 6, 2012
588e535
Merge branch 'master' of git://github.com/UWE-Ruby/RubyFall2012
kellimohr Nov 7, 2012
865c51f
rake exercises
kellimohr Nov 14, 2012
303af58
Merge branch 'master' of git://github.com/UWE-Ruby/RubyFall2012 into …
kellimohr Nov 14, 2012
6014747
Merge branch 'master' of git://github.com/UWE-Ruby/RubyFall2012 into …
kellimohr Nov 14, 2012
baacf52
merging changes
kellimohr Nov 21, 2012
a1ab4e6
Passed all cucmber test
kellimohr Nov 21, 2012
07551c4
Class Exercises
kellimohr Nov 26, 2012
1b4058c
merging changes
kellimohr Nov 26, 2012
5dc1247
Answered questions
kellimohr Nov 27, 2012
9086291
Homework
kellimohr Nov 27, 2012
dd40024
Finished pirate cucumber specs
kellimohr Nov 27, 2012
b84b650
Merge branch 'master' of git://github.com/UWE-Ruby/RubyFall2012 into …
kellimohr Nov 28, 2012
b27f5fc
metaprogramming example
kellimohr Nov 28, 2012
4bfcf04
start of tic tac toe
kellimohr Dec 4, 2012
83c8476
More TicTacToe
kellimohr Dec 4, 2012
65f5cbf
Test changes
kellimohr Dec 9, 2012
e8d36eb
passed first test
kellimohr Dec 11, 2012
c7e716d
passed another test
kellimohr Dec 11, 2012
03906d9
passed test 120
kellimohr Dec 11, 2012
e4494c3
30 tests passed
kellimohr Dec 11, 2012
64625a6
need to refactor smelly code
kellimohr Dec 11, 2012
eb09245
change to cucmber test
kellimohr Dec 11, 2012
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
18 changes: 0 additions & 18 deletions mid_term/wish_list_spec.rb

This file was deleted.

95 changes: 0 additions & 95 deletions week1/exercises/rspec_spec.rb

This file was deleted.

29 changes: 25 additions & 4 deletions week1/homework/questions.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
Please read:
Chapter 3 Classes, Objects, and Variables
p.90-94 Strings

1. What is an object?
<<<<<<< HEAD

Object is the root of Ruby's class hierarchy. Its methods are available to all classes unless explicitly overridden.

2. What is a variable?

A variable is a reference to an object.

3. What is the difference between an object and a class?

All objects are instances of a class.

4. What is a String?

A string is a sequence of characters. Strings are objects of class String.

5. What are three messages that I can send to a string object? Hint: think methods

downcase, upcase, strip

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

Two ways to define a String literal are single quoted string and double quoted string. A double quoted string can undergo additional subsitutions such as Tab, Space, Return, Escape or Backspace.
=======
An object is a representation in memory of a specific concept or thing that the Ruby interpreter knows about.

2. What is a variable?
Expand All @@ -22,3 +42,4 @@ split - returns an array of strings made up of the original string separated on
6. What are two ways of defining a String literal? Bonus: What is the difference between the two?
Single quotes ex: '' and Double quotes ex: "". The single qoutes allow for 2 escape characters: \' and \\ . The double qouted 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 qouted string takes up much less memory than a doulbe qouted string with interpolation. Without interpolation, both are about the same.

>>>>>>> ea9aa93fcf3644ee7d901c086bc1b1ebc77f6f44
13 changes: 12 additions & 1 deletion week1/homework/strings_and_rspec_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# encoding: utf-8
#encoding: utf-8

# Please make these examples all pass
# You will need to change the 3 pending tests
Expand All @@ -13,6 +13,16 @@
@my_string = "Renée is a fun teacher. Ruby is a really cool programming language"
end
it "should be able to count the charaters" do
<<<<<<< HEAD
@my_string.should have(66).characters
end
it "should be able to split on the . charater" do
result = @my_string.split(/\./)
result.should have(2).items
end
it "should be able to give the encoding of the string" do
#{@my_string.encoding} should eq (Encoding.find("UTF-8"))
=======
@my_string.should have(@my_string.size).characters
end
it "should be able to split on the . charater" do
Expand All @@ -21,6 +31,7 @@
end
it "should be able to give the encoding of the string" do
@my_string.encoding.should eq (Encoding.find("UTF-8"))
>>>>>>> ea9aa93fcf3644ee7d901c086bc1b1ebc77f6f44
end
end
end
12 changes: 12 additions & 0 deletions week2/exercises/book.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
class Book

<<<<<<< HEAD
attr_accessor :title, :page_count

def initialize(title, page_count)
@title = title
@page_count = page_count
end

def page_count
return "Page count is #{@page_count}"
=======
attr_accessor :title, :pages

def initialize(title, pages)
Expand All @@ -9,5 +20,6 @@ def initialize(title, pages)

def page_count
"Page count is #{@pages}"
>>>>>>> 476e4b543ee68aad8bb809afdfe2207afd39e8e5
end
end
4 changes: 4 additions & 0 deletions week2/exercises/book_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
require './book.rb'
<<<<<<< HEAD
require './spec_helper.rb'
=======
>>>>>>> 476e4b543ee68aad8bb809afdfe2207afd39e8e5

describe Book do
before :each do
Expand Down
Empty file added week2/exercises/lor
Empty file.
6 changes: 6 additions & 0 deletions week2/exercises/mad_libs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@
adjective = gets.chomp
puts "Please enter a past tense action verb"
verb_past_tense = gets.chomp
<<<<<<< HEAD
puts "Enter another noun"
noun1 = gets.chomp
story = "The #{adjective} #{noun} #{verb_past_tense} past the graveyard and ate the #{noun1}"
=======
puts "What does the #{noun} say?"
says = gets.chomp
story = "The #{adjective} #{noun} #{verb_past_tense} past the graveyard and says #{says}"
>>>>>>> 476e4b543ee68aad8bb809afdfe2207afd39e8e5
puts story
3 changes: 3 additions & 0 deletions week2/exercises/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
RSpec.configure do |config|
config.color_enabled = true
end
21 changes: 21 additions & 0 deletions week2/homework/questions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,26 @@ Containers, Blocks, and Iterators
Sharing Functionality: Inheritance, Modules, and Mixins

1. What is the difference between a Hash and an Array?
<<<<<<< HEAD

The difference between a Hash and an Array is a Hash can be indexed with an object of any type, such as a symbol or strig whereas an array is indexed with a non-negative integer.

2. When would you use an Array over a Hash and vice versa?

An array is useful for storing a list of items where an index isn't necessary. A hash would be used to store a collection of items with a descriptive index (key) for easier look-up later.

3. What is a module? Enumerable is a built in Ruby module, what is it?

A module groups together methods, classes and constants. Enumerable is a collecton of classes with traversal and searching methods with the ability to sort.

4. Can you inherit more than one thing in Ruby? How could you get around this problem?

Ruby is a single-inheritance language. Although you can use "mixins" and include a module within a class definition to access to the module's instance methods.

5. What is the difference between a Module and a Class?

The difference between a Module and a Class is that a module cannot be instantiated. A class may inherit from another class. A module cannot inherit from anything.
=======
An array is an ordered list of items that are referenced by their index (order), a hash is a collection of items that can be referenced by a key and have no order.

2. When would you use an Array over a Hash and vice versa?
Expand All @@ -16,3 +36,4 @@ No, multiple inheritance is not allowed in Ruby. You can include multiple module

5. What is the difference between a Module and a Class?
A class can be instantiated into an object, a module cannot. A module is code that can be used across many classes.
>>>>>>> 529b28228eac9e841374d40584eb6341ab03b2dd
37 changes: 37 additions & 0 deletions week2/homework/simon_says.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,40 @@
module SimonSays
<<<<<<< HEAD

def echo(word)
@word = word
return "#{@word}"
end

def shout(word)
@word = word.upcase
return "#{@word}"
end

def repeat(word, times=2)

@word = "#{word}"
@final_word = @word

for i in 1...times
@final_word = @final_word + " " + "#{word}"
end

return @final_word
end

def start_of_word(word, end_pnt)
@word = word
return @word[0...end_pnt]
end

def first_word(word)
@word = word.scan(/\w+/)
return @word[0]

end
end
=======
def echo(st)
st
end
Expand All @@ -20,3 +56,4 @@ def repeat(st, t=2)
([st]*t).join(' ')
end
end
>>>>>>> 529b28228eac9e841374d40584eb6341ab03b2dd
20 changes: 20 additions & 0 deletions week3/homework/calculator.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
class Calculator
<<<<<<< HEAD

def sum(num)
num.inject(0,:+)
end

def multiply(num)
num.inject(:*)
end

def power(num)
num.inject(:**)
end

def factorial(num)
(1..num).inject(0,:*)
end
end
=======
def sum(array)
array.inject(0){|sum, x| sum +x}
end
Expand All @@ -22,3 +41,4 @@ def pow_fac(base=nil, p)
(1..p).to_a.inject(1){|f,v| f *= base || v}
end
end
>>>>>>> f7e675fa7a88f9cdfc4b342f33e2567d897b5075
Loading