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

Submitting homework 7 #109

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Empty file added .travis.yml
Empty file.
1 change: 1 addition & 0 deletions gem_project_rubywinter2014
Submodule gem_project_rubywinter2014 added at f97791
4 changes: 4 additions & 0 deletions gem_test/gem_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
require 'open_exchange_rates_conversion'

new_currency = Converter.new
puts new_currency.currency_exchange('USD', 1, '912735b01e8143bf8dee944d7673ed06')
39 changes: 0 additions & 39 deletions midterm/instructions_and_questions.txt

This file was deleted.

74 changes: 0 additions & 74 deletions midterm/mid_term_spec.rb

This file was deleted.

18 changes: 0 additions & 18 deletions midterm/wish_list_spec.rb

This file was deleted.

Binary file added week1/.DS_Store
Binary file not shown.
33 changes: 16 additions & 17 deletions week1/exercises/rspec_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe "The Rspec ruby gem" do

context "Domain Specific Language" do
context "Domain Specific Language" do

it "creates examples with the #it keyword" do

Expand Down Expand Up @@ -63,34 +63,33 @@
end

it "should count the characters in my name" do
"Renée".should have(5).characters
"Renée".should have(5).characters
end

it "should check how to spell my name" do
"Renée".should include("ée")
"Renée".should include("ée")
end

end

context "Examples for in-class test exploration" do
it "should know order of operations" do
# 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 -6
it "should know order of operations" do
# 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 -6
end
it "should count the characters in your name" do
John.should have(4).characters
end
it "should count the characters in your name" do
"Tom".should have(3).characters
end

it "should check basic math" do
(40+2).should eq 42

it "should check basic math" do
2+2.should eq 4
end

it "should check basic spelling" do
"Field".should include('ie')
it "should check basic spelling" do
"spell".should include("ll")
end

end

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

1. What is an object?

An object holds information that methods can interavt with and manipulate. Everything in Ruby is an object.
2. What is a variable?
A variable is a place where information is stored that has a unique name identifier. They keep track of objects, and each variable is a reference to an object.

3. What is the difference between an object and a class?
Classes are created and defined, and they are define the paramters of objects. Objects are anything you can interact with in Ruby.

4. What is a String?
A string is a sequence of characters.

5. What are three messages that I can send to a string object? Hint: think methods
split, squeeze and chomp

6. What are two ways of defining a String literal? Bonus: What is the difference between them?
Single quotes and double quotes. The difference is the escape sequences you can use with each. Double quotes have more escape sequences available.
11 changes: 6 additions & 5 deletions 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 @@ -12,14 +12,15 @@
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"
it "should be able to count the charaters" do
@my_string.should have(66).charaters
end
it "should be able to split on the . charater" do
pending
result = #do something with @my_string here
result = @my_string.split(/\s*\.\s*/)
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"))'
puts "encoding of #{@my_string.inspect} is #{@my_string.encoding}"
end
end
end
Expand Down
5 changes: 5 additions & 0 deletions week2/homework/questions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@ Containers, Blocks, and Iterators
Sharing Functionality: Inheritance, Modules, and Mixins

1. What is the difference between a Hash and an Array?
A hash stores a whole integer while an array can hold any object.

2. When would you use an Array over a Hash and vice versa?
You would use a hash when you have a key and an object corresponding to that key, such as the key being "name" and the object being the person's name.

3. What is a module? Enumerable is a built in Ruby module, what is it?
A module is simliar to a library, and it interacts with functions to perform repeatable processes. Enumerable allows you to terminate a loop cleanly when there are no additional values.

4. Can you inherit more than one thing in Ruby? How could you get around this problem?
You cannot inherit more than one thing in Ruby, and you get around this with mixins.

5. What is the difference between a Module and a Class?
Modules interact with functions while classes are about objects.
19 changes: 19 additions & 0 deletions week2/homework/simon_says.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module SimonSays
def echo(string)
@string = string
end
def shout(string)
string = string.upcase
end
def repeat(string, x=2)
string = ((string + " ") * x).strip
end
def start_of_word(string, x)
x = x-1
string[0..x]
end
def first_word(string)
string = string.split(/\s+/)
string[0]
end
end
2 changes: 1 addition & 1 deletion week2/homework/simon_says_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@
it "should tell us the first word of 'oh dear' is 'oh'" do
first_word("oh dear").should == "oh"
end
end
end
21 changes: 21 additions & 0 deletions week3/exercises/book.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
class Book

<<<<<<< HEAD
attr_accessor :pages, :title

@@library_count = 0

def self.library_count
@@library_count
end

def initialize pages = 0, title="N/A"
@pages = pages
@title = title
@@library_count +=1
end

def happy
$global_hello = "hello"
"There are #{pages} happy pages in this book"
end
=======
def pages

end
>>>>>>> f7862ea7a840b4f8235c899e2c56a93c586fbd2d

end
37 changes: 36 additions & 1 deletion week3/exercises/book_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,45 @@
require './book.rb'

describe Book do
<<<<<<< HEAD

before :each do
@book = Book.new 542, "Programming Ruby"
end

context "::library_count" do
it "should tell us how many books are in our library" do
34233.times{ Book.new 3 }
Book.library_count.should eq 34234
end
end

context "#pages" do
it "should have a pages" do
@book.should respond_to "pages"
end

it "should allow us to set the number of pages" do
@book.pages.should eq 542
end
end

context "#title" do
it "should ket us set and get a title" do
@book.title.should eq "Programming Ruby"
end
end



end

=======

it "should have a pages" do
book = Book.new
book.should respond_to "pages"
end

end
end
>>>>>>> f7862ea7a840b4f8235c899e2c56a93c586fbd2d
Empty file added week3/homework/.travis.yml
Empty file.
Loading