diff --git a/week6/class_materials/test_gem/test_gem.gemspec b/week6/class_materials/test_gem/test_gem.gemspec index d2f86fc..2cd42c9 100644 --- a/week6/class_materials/test_gem/test_gem.gemspec +++ b/week6/class_materials/test_gem/test_gem.gemspec @@ -1,12 +1,12 @@ Gem::Specification.new do |s| - s.name = 'reneedv_hello_gem' + s.name = 'BrianTestGem' s.version = '0.0.1' s.date = '2012-11-13' s.summary = "Making a Test Gem" s.description = "A gem to explain how to make gems" - s.authors = ["Renée De Voursney"] - s.email = 'renee@nird.us' + s.authors = ["Brian Torretta"] + s.email = 'btorretta@gmail.com' s.homepage = 'http://rubygems.org/gems/test_gem' s.files = ["lib/test_gem.rb"] s.executables << 'test_gem' -end \ No newline at end of file +end diff --git a/week7/exercises/features/puppy.feature b/week7/exercises/features/puppy.feature deleted file mode 100644 index e6c7b07..0000000 --- a/week7/exercises/features/puppy.feature +++ /dev/null @@ -1,18 +0,0 @@ -Feature: Puppies are very cute and everyone wants one - In order to make everyone happy - As a puppy class programmer - I want to give everyone a cute virtual puppy - -Scenario: The puppy is being pet - Given we have a puppy - And its name is Fred - When we pet the puppy - Then the puppy wags its tail - -Scenario: The puppy needs to go out - Given we have a puppy - And its name is Bella - When we ring the bell - And it wags its tail - Then we must take it out - And then it will not pee on the floor diff --git a/week7/homework/features/step_definitions/pirate.rb b/week7/homework/features/step_definitions/pirate.rb new file mode 100644 index 0000000..53ad47b --- /dev/null +++ b/week7/homework/features/step_definitions/pirate.rb @@ -0,0 +1,13 @@ +# encoding: utf-8 +class Pirate +def initialize(value) +@value = value +end + +def translate(arg1) +if arg1 = ("Hello Friend") +then puts "Ahoy Matey" +puts "Shiber Me Timbers You Scurvey Dogs!!" +end +end +end diff --git a/week7/homework/features/step_definitions/pirate_steps.rb b/week7/homework/features/step_definitions/pirate_steps.rb new file mode 100644 index 0000000..57c5886 --- /dev/null +++ b/week7/homework/features/step_definitions/pirate_steps.rb @@ -0,0 +1,38 @@ +#Given /^I say (\hello friend\i)$/ do |arg1| + +# @pirate = Pirate.new(arg1) + +#end + + +#When /^I hit (\w+)$/ do |arg1| + +# @result = @pirate.send(arg1) + +#end + + +#Then /^Let go and haul it prints out (\Ahoy Matey\)(\Shiber Me Timbers You Scurvey Dogs!!\)$/ do |arg1, arg2| + +# @result.should == "#{arg1} #{arg2}" +#end +Gangway /^I have a PirateTranslator$/ do + @pirate = Pirate.new('Hello Friend') # express the regexp above with the code you wish you had +end + +Blimey /^I say 'Hello Friend'$/ do + @pirate# express the regexp above with the code you wish you had +end + +Blimey /^I hit translate$/ do + @pirate.translate("Hello Friend") # express the regexp above with the code you wish you had +end + +Letgoandhaul /^it prints out 'Ahoy Matey'$/ do + pending # express the regexp above with the code you wish you had +end + +Letgoandhaul /^it also prints 'Shiber Me Timbers You Scurvey Dogs!!'$/ do + pending # express the regexp above with the code you wish you had +end + diff --git a/week7/homework/features/step_definitions/tic-tac-toe.rb b/week7/homework/features/step_definitions/tic-tac-toe.rb new file mode 100644 index 0000000..c1ab80b --- /dev/null +++ b/week7/homework/features/step_definitions/tic-tac-toe.rb @@ -0,0 +1,90 @@ +# encoding: utf-8 +class TicTacToe + +SYMBOLS = [:X, :O] + + +attr_accessor :player, :X, :O + + def initialize(player = :player) + @new_game = true + @player = player + #owe the new game trick to kris-luminar + if player == "Renee" then current_player(Renee) end + + end + + def player(*player) + + #@player = player + i = puts "what is your name?" + player = gets.chomp + end + + + + def welcome_player + + "Welcome #{@player}" + end + + def current_player(*player) + # if @new_game == true + players = [player, "Computer"] + first = players.sample + if first = player then second = "Computer" else second = player + end + # end + + end + + def player_symbol + :X + end + + def computer_symbol + :O + end + + #def indicate_palyer_turn + #end + + #def get_player_move + #end + + #def open_spots + #end + + #def computer_move + #end + + #def current_state + #end + + # def spots_open? + #end + + # def spots_open? + #end + + #def player_won? + #end + + #def computer_won? + #end + + #def draw? + #end + + +@board = { + + A1: " ", A2: " ", A3: " ", + + B1: " ", B2: " ", B3: " ", + + C1: " ", C2: " ", C3: " " + + } + +end diff --git a/week7/homework/questions.txt b/week7/homework/questions.txt index d55387d..0374309 100644 --- a/week7/homework/questions.txt +++ b/week7/homework/questions.txt @@ -3,7 +3,12 @@ Please Read Chapters 23 and 24 DuckTyping and MetaProgramming Questions: 1. What is method_missing and how can it be used? +If a method isn't found is the current class or any superclass, Ruby invokes method_missing and typically raises a nomethoderror or name error. We can overwrite the default behaviour with it's own method and error handling. 2. What is and Eigenclass and what is it used for? Where Do Singleton methods live? +Eigenclass, or singleton class p.369, is the class that is specific to a particular object and it is anonymous class. Singleton methods in live in the class of Object. 3. When would you use DuckTypeing? How would you use it to improve your code? +DuckTyping is always used by Ruby and it always for shorter, more concise coding. 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 is a method that works on a class and an instance method is one that only works on an instance of that class. Instance eval and class eval let you set self to be an arbitrary object, evaluate the code in a block and then reset self. Class eval's environment acts as if you were in the body of a class definition so methods will define instance methods. instance eval acts as if you were working inside a singleton class of self and any methods you define will become class methods. 5. What is the difference between a singleton class and a singleton method? +They are either method or classes that are specific to a particular object.