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

week 9 gem uploaded - jonas haskins #119

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e15fe96
finished the homework!
Oct 15, 2013
7e6e8be
my homework
Oct 16, 2013
8c7cb8c
Merge branch 'master' of github.com:UWE-Ruby/RubyFall2013
Oct 16, 2013
8f4539f
Merge branch 'master' of github.com:UWE-Ruby/RubyFall2013
Oct 16, 2013
1dfb52e
Finished the homework questions, and the simon_says.rb module for hom…
sanojsniksah Oct 22, 2013
99b604b
Merge branch 'master' of github.com:UWE-Ruby/RubyFall2013
sanojsniksah Oct 23, 2013
433e2fe
my book exe
sanojsniksah Oct 24, 2013
3d0172c
spec file.
sanojsniksah Oct 24, 2013
0fc7874
exercises and stuff ...
sanojsniksah Oct 24, 2013
a2085b7
homework ! jonas haskins week 3
sanojsniksah Oct 30, 2013
2d2a8d3
Merge github.com:UWE-Ruby/RubyFall2013
sanojsniksah Nov 5, 2013
72c3def
Merge github.com:UWE-Ruby/RubyFall2013
sanojsniksah Nov 6, 2013
a52c98b
Merge branch 'master' of github.com:UWE-Ruby/RubyFall2013
sanojsniksah Nov 11, 2013
24c4b92
Initial commit
sanojsniksah Nov 11, 2013
a909850
Created the new depo and added the instructions to get started.
sanojsniksah Nov 11, 2013
24496d5
first draft of working even numbers and even numberes spec.
sanojsniksah Nov 12, 2013
65dc743
Merge branch 'master' of github.com:sanojsniksah/jonashaskins_midterm
sanojsniksah Nov 12, 2013
761d1b1
Merge branch 'master' of github.com:UWE-Ruby/RubyFall2013
sanojsniksah Nov 14, 2013
8816f5d
Merge branch 'master' of github.com:UWE-Ruby/RubyFall2013
sanojsniksah Nov 20, 2013
978f2c2
homework for week 7
sanojsniksah Nov 27, 2013
25791bd
Merge branch 'master' of github.com:UWE-Ruby/RubyFall2013
sanojsniksah Dec 3, 2013
767bfa4
Merge branch 'master' of github.com:UWE-Ruby/RubyFall2013
sanojsniksah Dec 3, 2013
3e357cf
Merge branch 'master' of github.com:UWE-Ruby/RubyFall2013
sanojsniksah Dec 5, 2013
2b2f5ae
added all these goodies and the .travis.yml
sanojsniksah Dec 6, 2013
d0378b1
fixed a issue with .travis.yml
sanojsniksah Dec 6, 2013
e2d9429
added my gem.
sanojsniksah 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
Binary file added .DS_Store
Binary file not shown.
48 changes: 0 additions & 48 deletions .rvmrc

This file was deleted.

7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<<<<<<< HEAD
RubyFall2013
============

Expand Down Expand Up @@ -57,3 +58,9 @@ Week 10
* Final due!
* Project due!
* Interesting Stuff
=======
jonashaskins_midterm
====================

keeps my midter
>>>>>>> a909850fc83ae544cc25011759e2c6217f254bb5
39 changes: 39 additions & 0 deletions instructions_and_questions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Instructions for Mid-Term submission and Git Review (10pts):
- Create a git repository for your answers
- Add and Commit as you work through the questions and programming problems
- Your git log should reflect your work, don't just commit after you have finished working
- Use .gitignore to ignore any files that are not relevant to the midterm
- E-mail me your ssh public key
- I will email you back with your repository name
- Add a remote to your git repository: [email protected]:RubyFall2013/YOURREPOSITORYNAME.git
- Push your changes to the remote
- After 6pm Tuesday November 19th you will not be able to push to your remote repository (or clone).

Questions (20pts):
- What are the three uses of the curly brackets {} in Ruby?
- What is a regular expression and what is a common use for them?
- What is the difference between how a String, a symbol, a FixNum, and a Float are stored in Ruby?
- Are these two statements equivalent? Why or Why Not?
1. x, y = "hello", "hello"
2. x = y = "hello"
- What is the difference between a Range and an Array?
- Why would I use a Hash instead of an Array?
- What is your favorite thing about Ruby so far?
- What is your least favorite thing about Ruby so far?

Programming Problems (10pts each):
- Write a passing rspec file called even_number_spec.rb that tests a class called EvenNumber.
- The EvenNumber class should:
- Only allow even numbers
- Get the next even number
- Compare even numbers
- Generate a range of even numbers
- Make the rspec tests in wish_list_spec.rb pass by writing a WishList class
- The WishList class should:
- Mixin Enumerable
- Define each so it returns wishes as strings with their index as part of the string

Mid-Term Spec (50pts):
- Make the tests pass.


74 changes: 74 additions & 0 deletions mid_term_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
require "#{File.dirname(__FILE__)}/turkey"

describe Turkey do

before do
@turkey = Turkey.new(10)
end

it "should report the turkey weight" do
@turkey.weight.should equal 10
end

it "should be a kind of animal" do
@turkey.kind_of?(Animal).should be_true
end

it "should gobble speak" do
@turkey.gobble_speak("Hello I Am a Turkey. Please Don't Eat Me.").should eq "Gobble Gobble Gobble gobble Gobble. Gobble Gobb'le Gobble Gobble."
end

end

require "#{File.dirname(__FILE__)}/thanksgiving_dinner"

describe ThanksgivingDinner do

before do
@t_dinner = ThanksgivingDinner.new(:vegan)
@t_dinner.guests = ["Aunt Petunia", "Uncle Vernon", "Aunt Marge", "Dudley", "Harry"] # I know I just made a British family celebrate Thanksgiving, but it could be worse: It could have been the 4th of July! :)
end

it "should be a kind of dinner" do
@t_dinner.kind_of?(Dinner).should be_true
end

# Use inject here
it "should sum the letters in each guest name for the seating chart size" do
@t_dinner.seating_chart_size.should eq 45
end

it "should provide a menu" do
@t_dinner.respond_to?(:menu).should be_true
end

context "#menu" do

it "should have a diet specified" do
@t_dinner.menu[:diet].should eq :vegan
end

it "should have proteins" do
@t_dinner.menu[:proteins].should eq ["Tofurkey", "Hummus"]
end

it "should have vegetables" do
@t_dinner.menu[:veggies].should eq [:ginger_carrots , :potatoes, :yams]
end

# Dinners don't always have dessert, but ThanksgivingDinners always do!
it "should have desserts" do
@t_dinner.menu[:desserts].should eq({:pies => [:pumkin_pie], :other => ["Chocolate Moose"], :molds => [:cranberry, :mango, :cherry]})
end

end

# Use String interpolation, collection methods, and string methods for these two examples
it "should return what is on the dinner menu" do
@t_dinner.whats_for_dinner.should eq "Tonight we have proteins Tofurkey and Hummus, and veggies Ginger Carrots, Potatoes, and Yams."
end

it "should return what is on the dessert menu" do
@t_dinner.whats_for_dessert.should eq "Tonight we have 5 delicious desserts: Pumkin Pie, Chocolate Moose, and 3 molds: Cranberry and Mango and Cherry."
end
end
Empty file added midterm/README.md
Empty file.
19 changes: 19 additions & 0 deletions midterm/even_number.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class EvenNumber

def even(number)
number.even?
end

def next_even(nextnumber)
nexteven = nextnumber + 2
end

def compair(num1, num2)
num1 <=> num2
end

def makerange(range)
a = range
b = a.select {|x| x.even? }
end
end
32 changes: 32 additions & 0 deletions midterm/even_number_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require "#{File.dirname(__FILE__)}/even_number"

describe EvenNumber do

before do
@number = EvenNumber.new
end

it "Should only allow even numbers" do
@number.even(6).should eq true
@number.even(7).should eq false
end

it "Should get the next even number" do
a = 10
b = a + 2
@number.next_even(a).should == b
end

it "Should compair two even numbers" do
@number.compair(8, 8).should == 0
@number.compair(8, 6).should == 1
@number.compair(6, 8).should == -1
end

it "Should generate a range of even numbers" do
a = 2..20
b = a.select {|x| x.even? }
@number.makerange(2..20).should eq b
end

end
Binary file added week1/.DS_Store
Binary file not shown.
8 changes: 8 additions & 0 deletions week1/class_materials/name_printer_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
describe "NamePrinter Application" do

context "When Somethings Happens When I'm Logged In" do
it "should say Something" do
"Something".should eq "Something"
end
end
end
30 changes: 22 additions & 8 deletions week1/exercises/rspec_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,14 @@

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

end

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

# jhjh
it "supports placeholder examples that lack code (like this one)" do
1.should eq 1
end

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

Expand All @@ -71,21 +74,32 @@
end

end

## JHJH added class tests
context "When Somethings Happens When I'm Logged In" do
it "should say Something" do
"Something".should eq "Something"
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 -13
(1+2-5*6/2).should eq -12
end
it "should count the characters in your name" do
pending

context "Count my name" do
it "should count the characters in your name" do
"Jonas".should have(5).characters
end
end

it "should check basic math"
it "should check basic math"

it "should check basic spelling"
it "should check basic spelling"

end

Expand Down
32 changes: 32 additions & 0 deletions week1/homework/questions.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,47 @@
Please read:
Chapter 3 Classes, Objects, and Variables

p.86-90 Strings (Strings section in Chapter 6 Standard Types)

1. What is an object?
a instance of a class.

2. What is a variable?
a reference to a object

3. What is the difference between an object and a class?
a class is a combination of state and methods. an object is a instance of that class ( class instance ).


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

5. What are three messages that I can send to a string object? Hint: think methods
chomp, count, delete, empty? , length, upcase, downcase, split, squeeze! ... woah there are alot.


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

single or double quotation marks.

single quotes 'foo', foo becomes the value.
For Double quotes, "foo\nbar" ruby looks for substitutions, interpolation "#{foo}" and escape sequences "Foo \nBar"

also %q ( single quotes ), %Q ( double quotes )

%q/foo bar/
%Q!oh no #{crap}!

you can choose a delimiter.

Finally here documents.

string = << HERE
some kinda text
about something
i forgot what
HERE



check them in and send a pull request !!
29 changes: 25 additions & 4 deletions week1/homework/strings_and_rspec_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,35 @@
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
result = @my_string.count @my_string
result.should eq 66
#puts "Count is #{result}"

# These work to
# white space are characters to
# size = @my_string.size
# size.should eq 66
# puts "Size is #{size}"

# delete the white spaces !
# @new_string = @my_string.delete(' ')
# size = @new_string.size
# size.should eq 55
# puts "Size is #{size}"

end

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"))'
#pending 'helpful hint: should eq (Encoding.find("UTF-8"))'
"#{@my_string.encoding}".should eq "UTF-8"
#puts "Encoding of #{@my_string.inspect} is #{@my_string.encoding}"


end
end
end
Expand Down
Loading