diff --git a/week1/class_materials/name_printer_spec.rb b/week1/class_materials/name_printer_spec.rb new file mode 100644 index 0000000..9bd2e7f --- /dev/null +++ b/week1/class_materials/name_printer_spec.rb @@ -0,0 +1,11 @@ +describe "NamePrinter Application" do + + context "When Renee is logged in " do + + it "should say Renee" do + + "Renee".should eq "Renee" + + end + end +end \ No newline at end of file diff --git a/week1/exercises/rspec_spec.rb b/week1/exercises/rspec_spec.rb index 1e0a8ef..9cb1a9d 100644 --- a/week1/exercises/rspec_spec.rb +++ b/week1/exercises/rspec_spec.rb @@ -41,7 +41,7 @@ it "alerts you when examples fail" do - # When this example fails, + # When this example fails, # it will show "expected" as 2, and "actual" as 1 1.should eq 2 @@ -53,7 +53,7 @@ # The following expression is false. # However, this example PASSES because no expectation was created. - true == false + true.should eq true # The following line of code is correct, and would cause the example to fail: # true.should == false @@ -77,15 +77,25 @@ # 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 + "Kate".should have(4).characters end - it "should check basic math" + it "should check basic math" do + + (14*2).should eq 28 + + end + + + it "should check basic spelling" do + + "Fox".should eq "Fox" + + end - it "should check basic spelling" end diff --git a/week1/homework/questions.txt b/week1/homework/questions.txt index bd581a6..4737b06 100644 --- a/week1/homework/questions.txt +++ b/week1/homework/questions.txt @@ -3,13 +3,15 @@ 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 container for info related to a certain thing that also allow you to perform actions on it. 2. What is a variable? - + Variables are storage locations for data to allow a reference to said data. 3. What is the difference between an object and a class? - + Objects are manifestations of our class. + Example, BookInStock is the class that defines b1, b2, and other objects which are instantiates of it. 4. What is a String? - + Strings are sequences of characters. They normally contain printable characters but that is not a requirement; they can also hold binary data. Strings are objects of class String. 5. What are three messages that I can send to a string object? Hint: think methods - + split, chomp, squeeze, scan 6. What are two ways of defining a String literal? Bonus: What is the difference between the two? + double quotes "" or here documents \ No newline at end of file diff --git a/week1/homework/strings_and_rspec_spec.rb b/week1/homework/strings_and_rspec_spec.rb index ea79e4c..505e0e4 100644 --- a/week1/homework/strings_and_rspec_spec.rb +++ b/week1/homework/strings_and_rspec_spec.rb @@ -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(".") #doing something with @my_string here 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.to_s.should include("UTF-8") end end end diff --git a/week2/class_materials/week2.pdf b/week2/class_materials/week2.pdf index 93497a0..4c62c88 100644 Binary files a/week2/class_materials/week2.pdf and b/week2/class_materials/week2.pdf differ diff --git a/week2/exercises/book.rb b/week2/exercises/book.rb index a6b943d..ad88c25 100644 --- a/week2/exercises/book.rb +++ b/week2/exercises/book.rb @@ -14,7 +14,6 @@ def initialize title = "Not Set", page_count = 0 @title = title end - def test @test = "Hello!" end @@ -24,4 +23,4 @@ def out_put_test puts @@book_count end -end \ No newline at end of file +end diff --git a/week2/exercises/book_spec.rb b/week2/exercises/book_spec.rb index c3b1292..b099678 100644 --- a/week2/exercises/book_spec.rb +++ b/week2/exercises/book_spec.rb @@ -1,4 +1,31 @@ -require './book' +# <<<<<<< HEAD +require 'C:\Sites\RubyFall2013\week2\exercises\book.rb' + +# describe Book do + +# context "::book_count" do +# it "should count how many books have been created" +# Book.new +# Book.new +# Book.new +# Book.book_count.should eq 3 +# end + +# before :each do +# @book = Book.new("Harry Potter", 200) +# end +# it "should respond to title" do +# @book.should respond_to "title" +# end + +# it "should return the page count" do +# @book.page_count.should eq "Page count is 200" +# end + + +# end +# ======= +# require './book' describe Book do @@ -46,4 +73,5 @@ end -end \ No newline at end of file +end +# >>>>>>> upstream/master diff --git a/week2/exercises/book_spec_ex.rb b/week2/exercises/book_spec_ex.rb new file mode 100644 index 0000000..9a4231c --- /dev/null +++ b/week2/exercises/book_spec_ex.rb @@ -0,0 +1,11 @@ +require 'C:\Sites\RubyFall2013\week2\exercises\book.rb' + +describe Book do + + it "should have a title" do + book = Book.new + book.should respond_to "title" + end + + +end \ No newline at end of file diff --git a/week2/exercises/books_spec.rb b/week2/exercises/books_spec.rb new file mode 100644 index 0000000..b9c1392 --- /dev/null +++ b/week2/exercises/books_spec.rb @@ -0,0 +1,49 @@ +require 'C:\Sites\RubyFall2013\week2\exercises\book.rb' + +describe Book do + + + context "::book_count" do + + it "should count how many books have been created" do + Book.new + Book.new + Book.new + Book.book_count.should eq 3 + end + + end + + context "::new" do + + it "should set some defaults" do + Book.new.title.should eq "Not Set" + end + + it "should allow us to set the page count" do + book = Book.new "Harry Potter", 5 + book.page_count.should eq 5 + end + + end + + context "#title" do + + before :each do + @book = Book.new + end + + it "should have a title" do + @book.should respond_to "title" + end + + it "should allow me to set the title" do + @book.title = "Snow Crash" + @book.title.should eq "Snow Crash" + end + + + + end + +end \ No newline at end of file diff --git a/week2/exercises/mad_lib.rb b/week2/exercises/mad_lib.rb new file mode 100644 index 0000000..e69de29 diff --git a/week2/homework/questions.txt b/week2/homework/questions.txt index 939e42d..8c52802 100644 --- a/week2/homework/questions.txt +++ b/week2/homework/questions.txt @@ -3,11 +3,19 @@ Containers, Blocks, and Iterators Sharing Functionality: Inheritance, Modules, and Mixins 1. What is the difference between a Hash and an Array? - + Arrays index with integers and hashes index with keys(objects of any type) 2. When would you use an Array over a Hash and vice versa? - + I would use an array for anything I needed an ordered list of items. + Hashes are powerful and would be helpful in many scenarios including but not limited to: + Storing Country names as values with the two letter abbreviation as keys. 3. What is a module? Enumerable is a built in Ruby module, what is it? - + Modules are ways of grouping methods, constants, and classes. + Enumerable is a module containing methods for all kinds of collection tasks. 4. Can you inherit more than one thing in Ruby? How could you get around this problem? - + No, Ruby is a single inheritance language. + You can include the functions of any number of mixins. 5. What is the difference between a Module and a Class? + Modules cannot create instances of itself, classes can create instance objects. + You can mixin a module into a class or another module augmenting the class or module its mixed into with it's methods and constants. + Classes cannot be mixed into other classes or modules. + Classes may inherit from one other class. Modules cannot inherit from anything. \ No newline at end of file diff --git a/week2/homework/simon_says.rb b/week2/homework/simon_says.rb new file mode 100644 index 0000000..b2204a1 --- /dev/null +++ b/week2/homework/simon_says.rb @@ -0,0 +1,22 @@ +module SimonSays + + def echo(word) + word + end + + def shout(word) + word.upcase + end + + def repeat(word, n = 2) + ([word] * n).join " " + end + + def start_of_word(word, n) + word[0...n] + end + + def first_word(word) + word.split(' ').first + end +end \ No newline at end of file diff --git a/week2/homework/simon_says_spec.rb b/week2/homework/simon_says_spec.rb index 7f329e5..3eb2eb7 100644 --- a/week2/homework/simon_says_spec.rb +++ b/week2/homework/simon_says_spec.rb @@ -1,5 +1,5 @@ # Hint: require needs to be able to find this file to load it -require "./simon_says.rb" +require 'C:\Sites\RubyFall2013\week2\homework\simon_says.rb' describe SimonSays do include SimonSays # Hint: Inclusion is different than SimonSays.new (read about modules) diff --git a/week3/homework/calculator.rb b/week3/homework/calculator.rb new file mode 100644 index 0000000..f5227b7 --- /dev/null +++ b/week3/homework/calculator.rb @@ -0,0 +1,26 @@ +class Calculator + + def sum array + if array == [] + 0 + else + array.inject{|n, x| n += x} + end + end + + def multiply (*number) + number.flatten.inject{|n,x| n *= x} + end + + def pow a, n + a ** n + end + + def fac n + if n == 0 + 1 + else + n * fac(n-1) + end + end +end \ No newline at end of file diff --git a/week3/homework/calculator2.rb b/week3/homework/calculator2.rb new file mode 100644 index 0000000..7a59801 --- /dev/null +++ b/week3/homework/calculator2.rb @@ -0,0 +1,16 @@ +class Calculator + def sum input + /result = 0 + input.each do |i| + result += i + end + result/ + #input.inject(0){|result, i| result+=i} + input.inject(0, :+) + end + def multiply a,b + #a*b + inputs.flatten.inject(:*) + end + +end \ No newline at end of file diff --git a/week3/homework/calculator_spec.rb b/week3/homework/calculator_spec.rb index 5a418ed..3d7dcc3 100644 --- a/week3/homework/calculator_spec.rb +++ b/week3/homework/calculator_spec.rb @@ -34,14 +34,17 @@ it "multiplies an array of numbers" do @calculator.multiply([2,2]).should eq 4 end - end - it "raises one number to the power of another number" do - p = 1 - 32.times{ p *= 2 } - @calculator.pow(2,32).should eq p end - + + describe "#pow" do + it "raises one number to the power of another number" do + p = 1 + 32.times{ p *= 2 } + @calculator.pow(2,32).should eq p + end + end + # http://en.wikipedia.org/wiki/Factorial describe "#factorial" do it "computes the factorial of 0" do diff --git a/week3/homework/questions.txt b/week3/homework/questions.txt index dfb158d..4f86df0 100644 --- a/week3/homework/questions.txt +++ b/week3/homework/questions.txt @@ -5,11 +5,15 @@ Please Read: - Chapter 22 The Ruby Language: basic types (symbols), variables and constants 1. What is a symbol? - + a symbols are constant names that you don't have to predeclare and tha re guaranteed to be uniquew 2. What is the difference between a symbol and a string? - + symbols are immutable and are purely internal identifiers + strings are mutable and can be used externally 3. What is a block and how do I call a block? - + A block is a chunk of code enclosed between two curly braces o the keywords do and end. + call a block directly after the parameters of a method 4. How do I pass a block to a method? What is the method signature? - + put the start of the block at the end of the source line containing the method call. + method signature includes method name and the number and order of its parameters 5. Where would you use regular expressions? + In String comparison, replacement, extraction, and other scenarios. \ No newline at end of file diff --git a/week4/class_materials/code_timer.rb b/week4/class_materials/code_timer.rb new file mode 100644 index 0000000..52f2cf7 --- /dev/null +++ b/week4/class_materials/code_timer.rb @@ -0,0 +1,9 @@ +Class Timer + + def self.time_code + start_time = Time.now + yield + Time.now - start_time + end + +end \ No newline at end of file diff --git a/week4/class_materials/code_timer_spec.rb b/week4/class_materials/code_timer_spec.rb new file mode 100644 index 0000000..e17f795 --- /dev/null +++ b/week4/class_materials/code_timer_spec.rb @@ -0,0 +1,26 @@ +require "#{File.dirname(__FILE__)}/code_timer" + +describe Timer2 do + + it "should run our code" do + flag = false + + CodeTimer.time_code do + flag = true + end + + flag.should eq true + + end + + it "should time our code" do + + run_time = CodeTimer.time_code do + sleep(3) + puts "hi" + end + + run_time.should be_within(0.1).of(3.0) + end + +end \ No newline at end of file diff --git a/week4/class_materials/timer2.rb b/week4/class_materials/timer2.rb new file mode 100644 index 0000000..52f2cf7 --- /dev/null +++ b/week4/class_materials/timer2.rb @@ -0,0 +1,9 @@ +Class Timer + + def self.time_code + start_time = Time.now + yield + Time.now - start_time + end + +end \ No newline at end of file diff --git a/week4/class_materials/timer_spec.rb b/week4/class_materials/timer_spec.rb index f71414a..e4b1ff7 100644 --- a/week4/class_materials/timer_spec.rb +++ b/week4/class_materials/timer_spec.rb @@ -18,9 +18,9 @@ end it "should run our code multiple times" do - counter = 0 + counter = 3 result = Timer.time_code(17) {counter += 1} - counter.should equal 17 + counter.should equal 20 end it "should give the average time" do diff --git a/week4/class_materials/timer_spec_2.rb b/week4/class_materials/timer_spec_2.rb new file mode 100644 index 0000000..e17f795 --- /dev/null +++ b/week4/class_materials/timer_spec_2.rb @@ -0,0 +1,26 @@ +require "#{File.dirname(__FILE__)}/code_timer" + +describe Timer2 do + + it "should run our code" do + flag = false + + CodeTimer.time_code do + flag = true + end + + flag.should eq true + + end + + it "should time our code" do + + run_time = CodeTimer.time_code do + sleep(3) + puts "hi" + end + + run_time.should be_within(0.1).of(3.0) + end + +end \ No newline at end of file diff --git a/week4/exercises/worker.rb b/week4/exercises/worker.rb new file mode 100644 index 0000000..7b3bac8 --- /dev/null +++ b/week4/exercises/worker.rb @@ -0,0 +1,6 @@ +class Worker + def self.work(n=1) + (n-1).times{yield} + yield + end +end \ No newline at end of file diff --git a/week4/exercises/worker_spec.rb b/week4/exercises/worker_spec.rb index dfc6f02..81e7382 100644 --- a/week4/exercises/worker_spec.rb +++ b/week4/exercises/worker_spec.rb @@ -17,11 +17,11 @@ end it "executes a block in the context of the calling method" do - n = 1 + n = 3 result = Worker.work do n + 4 end - result.should == 5 + result.should == 7 end diff --git a/week4/homework/questions.txt b/week4/homework/questions.txt index bc1ab7c..3b861f1 100644 --- a/week4/homework/questions.txt +++ b/week4/homework/questions.txt @@ -3,7 +3,13 @@ Chapter 10 Basic Input and Output The Rake Gem: http://rake.rubyforge.org/ 1. How does Ruby read files? + Ruby uses same methods for basic I/O for all file object. I.e. gets, puts, etc 2. How would you output "Hello World!" to a file called my_output.txt? + File.open("my_output.txt") do |file| + file.puts "Hello World!" + end 3. What is the Directory class and what is it used for? + 4. What is an IO object? 5. What is rake and what is it used for? What is a rake task? + \ No newline at end of file diff --git a/week5/exercises/rakeFile.rb b/week5/exercises/rakeFile.rb new file mode 100644 index 0000000..2db2b97 --- /dev/null +++ b/week5/exercises/rakeFile.rb @@ -0,0 +1,5 @@ + +task :read do +File.open("names") do |f| +f.read +end \ No newline at end of file diff --git a/week5/exercises/readRake.rb b/week5/exercises/readRake.rb new file mode 100644 index 0000000..6f79198 --- /dev/null +++ b/week5/exercises/readRake.rb @@ -0,0 +1,4 @@ + + +f = File.open("names") +f.read \ No newline at end of file diff --git a/week6/homework/gem/bonjour-0.0.0.gem b/week6/homework/gem/bonjour-0.0.0.gem new file mode 100644 index 0000000..d0aad43 Binary files /dev/null and b/week6/homework/gem/bonjour-0.0.0.gem differ diff --git a/week6/homework/gem/bonjour-styerfoam-0.0.0.gem b/week6/homework/gem/bonjour-styerfoam-0.0.0.gem new file mode 100644 index 0000000..59c1aa5 Binary files /dev/null and b/week6/homework/gem/bonjour-styerfoam-0.0.0.gem differ diff --git a/week6/homework/gem/bonjour-styerfoam.gemspec b/week6/homework/gem/bonjour-styerfoam.gemspec new file mode 100644 index 0000000..73afea6 --- /dev/null +++ b/week6/homework/gem/bonjour-styerfoam.gemspec @@ -0,0 +1,13 @@ +Gem::Specification.new do |s| + s.name = 'bonjourStyerfoam' + s.version = '0.0.0' + s.date = '2013-11-17' + s.summary = "My first gem" + s.description = "A simple hello world gem" + s.authors = "Kate Styer" + s.email = "styerfoaming@gmail.com" + s.files = ["lib/bonjour.rb"] + s.homepage = 'https://rubygems.org/gems/bonjour-styerfoam' + s.license = 'MIT' + +end diff --git a/week6/homework/gem/bonjourStyerfoam-0.0.0.gem b/week6/homework/gem/bonjourStyerfoam-0.0.0.gem new file mode 100644 index 0000000..218fd6c Binary files /dev/null and b/week6/homework/gem/bonjourStyerfoam-0.0.0.gem differ diff --git a/week6/homework/gem/lib/bonjour.rb b/week6/homework/gem/lib/bonjour.rb new file mode 100644 index 0000000..774fe26 --- /dev/null +++ b/week6/homework/gem/lib/bonjour.rb @@ -0,0 +1,6 @@ +class Bonjour + def self.hi + puts "hello world!" + end + +end \ No newline at end of file diff --git a/week7/class_materials/cucumber/features/step_definitions/converter_steps.rb b/week7/class_materials/cucumber/features/step_definitions/converter_steps.rb index 61b9aae..c3ef97d 100644 --- a/week7/class_materials/cucumber/features/step_definitions/converter_steps.rb +++ b/week7/class_materials/cucumber/features/step_definitions/converter_steps.rb @@ -12,4 +12,4 @@ Then /^the result should be (\d+)\.(\d+) on the screen$/ do |arg1, arg2| @result.should eq "#{arg1}.#{arg2}".to_f -end +end \ No newline at end of file diff --git a/week7/exercises/features/converter.feature b/week7/exercises/cucumber/features/converter.feature similarity index 100% rename from week7/exercises/features/converter.feature rename to week7/exercises/cucumber/features/converter.feature diff --git a/week7/exercises/cucumber/features/step_definitions/converter.rb b/week7/exercises/cucumber/features/step_definitions/converter.rb new file mode 100644 index 0000000..4e31bc5 --- /dev/null +++ b/week7/exercises/cucumber/features/step_definitions/converter.rb @@ -0,0 +1,18 @@ +class Converter + + def initialize(unit) + @unit = unit.to_f + end + + def type=(type) + @type = type + end + + def convert + self.send("#{@type}_conversion") + end + + def Fahrenheit_conversion + ((@unit - 32.0) *(5.0/9.0)).round(1) + end +end \ No newline at end of file diff --git a/week7/exercises/cucumber/features/step_definitions/converter_steps.rb b/week7/exercises/cucumber/features/step_definitions/converter_steps.rb new file mode 100644 index 0000000..272973d --- /dev/null +++ b/week7/exercises/cucumber/features/step_definitions/converter_steps.rb @@ -0,0 +1,15 @@ +Given /^I have entered (\d+) into the converter$/ do |arg1| + @converter = Converter.new(arg1) +end + +Given /^I set the type to (\w*)$/ do |arg1| + @converter.type = arg1 +end + +When /^I press convert$/ do + @result = @converter.convert +end + +Then /^the result returned should be (\d+)\.(\d+)$/ do |arg1, arg2| + @result.should eq "#{arg1}.#{arg2}".to_f +end \ No newline at end of file diff --git a/week7/homework/features/pirate.feature b/week7/holder_folder/pirate.feature similarity index 100% rename from week7/homework/features/pirate.feature rename to week7/holder_folder/pirate.feature diff --git a/week7/homework/features/step_definitions/pirate_steps.rb b/week7/holder_folder/pirate_steps.rb similarity index 100% rename from week7/homework/features/step_definitions/pirate_steps.rb rename to week7/holder_folder/pirate_steps.rb diff --git a/week7/holder_folder/pirate_translator.rb b/week7/holder_folder/pirate_translator.rb new file mode 100644 index 0000000..980913c --- /dev/null +++ b/week7/holder_folder/pirate_translator.rb @@ -0,0 +1,13 @@ +class PirateTranslator + + def say phrase + @phrase = phrase + end + + def translate + if @phrase == "Hello Friend" + return "Ahoy Matey\n Shiber Me Timbers You Scurvey Dogs!!" + end + end +end + diff --git a/week7/homework/features/step_definitions/tic-tac-toe-steps.rb b/week7/homework/cucumber/features/step_definitions/tic-tac-toe-steps.rb similarity index 99% rename from week7/homework/features/step_definitions/tic-tac-toe-steps.rb rename to week7/homework/cucumber/features/step_definitions/tic-tac-toe-steps.rb index a3287c1..a9bd88e 100644 --- a/week7/homework/features/step_definitions/tic-tac-toe-steps.rb +++ b/week7/homework/cucumber/features/step_definitions/tic-tac-toe-steps.rb @@ -35,7 +35,7 @@ Then /^the computer prints "(.*?)"$/ do |arg1| @game.should_receive(:puts).with(arg1) - @game.indicate_palyer_turn + @game.indicate_player_turn end Then /^waits for my input of "(.*?)"$/ do |arg1| diff --git a/week7/homework/cucumber/features/step_definitions/tictactoe.rb b/week7/homework/cucumber/features/step_definitions/tictactoe.rb new file mode 100644 index 0000000..b63998e --- /dev/null +++ b/week7/homework/cucumber/features/step_definitions/tictactoe.rb @@ -0,0 +1,63 @@ +class TicTacToe + + #require Random + + attr_accessor :player, :computer, :player_symbol, :computer_symbol + + SYMBOLS = ["X", "O"] + + def initialize current_player_name = "", current_player_symbol = :O + puts current_player_name + puts current_player_symbol + + if current_player_name == :computer + @computer_symbol = current_player_symbol + if @computer_symbol == :X + @player_symbol = :O + else + @player_symbol = :X + end + else + @player_symbol = current_player_symbol + if @player_symbol == :X + @computer_symbol = :O + else + @computer_symbol = :X + end + end + + if current_player_name == :player + @player = "Renee" + + else + @player = current_player_name.to_s.capitalize + + end + + @current_player = @player + + + @computer = "Computer" + # @player_symbol = player_symbol.to_s.capitalize + # @computer_symbol = computer_symbol.to_s.capitalize + end + + + def welcome_player + "Welcome #{@player}" + end + + def current_player + @current_player + + end + + def indicate_player_turn + puts "#{current_player}'s Move:" + end + + def get_player_move + gets + end + +end \ No newline at end of file diff --git a/week7/homework/features/tic-tac-toe.feature b/week7/homework/cucumber/features/tic-tac-toe.feature similarity index 100% rename from week7/homework/features/tic-tac-toe.feature rename to week7/homework/cucumber/features/tic-tac-toe.feature diff --git a/week7/homework/play_game.rb b/week7/homework/cucumber/play_game.rb similarity index 100% rename from week7/homework/play_game.rb rename to week7/homework/cucumber/play_game.rb diff --git a/week7/homework/questions.txt b/week7/homework/questions.txt index d55387d..ada60da 100644 --- a/week7/homework/questions.txt +++ b/week7/homework/questions.txt @@ -3,7 +3,19 @@ Please Read Chapters 23 and 24 DuckTyping and MetaProgramming Questions: 1. What is method_missing and how can it be used? + helps provide a catching mechanism for NoMethodError exceptions. + example def method_missing(method, *args, &block) + puts "there is no method called #{method} -- please try again." + end 2. What is and Eigenclass and what is it used for? Where Do Singleton methods live? + Eigenclass is a hidden class associated with each specific instance of another class. + a new anonymous class is created to hold an object's singleton methods. 3. When would you use DuckTypeing? How would you use it to improve your code? + 4. What is the difference between a class method and an instance method? What is the difference between instance_eval and class_eval? + a class method acts on a class directly and has no access to the individual instance variable methods + instance methods would have access to the actual variables of that instance + instance_eval will evaluate code against a singular instance of an object + class_eval in the context of the module or class 5. What is the difference between a singleton class and a singleton method? + I am feeling really turned around by the meta programming stuff. I don't know that I have an answer for this one. I am not even sure my answer for the others make sense \ No newline at end of file diff --git a/week7/exercises/features/puppy.feature b/week7/puppy.feature similarity index 100% rename from week7/exercises/features/puppy.feature rename to week7/puppy.feature diff --git a/week8/exercises/couch.rb b/week8/exercises/couch.rb index b8c8d4b..1fcd88b 100644 --- a/week8/exercises/couch.rb +++ b/week8/exercises/couch.rb @@ -9,4 +9,19 @@ def initialize(pillows, cushions) instance_variable_get("@#{s}").count end end -end \ No newline at end of file + + [:pillows, :cushions, :dogs].each do |s| + define_method("what_are_#{s}") do + instance_variable_get("@#{s}").each do |colors| + puts colors + end + end + end + + def method_missing method_name, *args, &block + puts "You called #{method_name} with #{args}" + end + + +end +