From cdeab056839c7651cc4b1b27af461dc3bb30a31d Mon Sep 17 00:00:00 2001 From: Jack Howland Date: Thu, 16 Jan 2014 14:38:33 -0800 Subject: [PATCH 1/7] jack1:submit homework --- week1/homework/answers.txt | 16 ++++++++++++++++ week1/homework/strings_and_rspec_spec.rb | 8 +++++++- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 week1/homework/answers.txt diff --git a/week1/homework/answers.txt b/week1/homework/answers.txt new file mode 100644 index 0000000..20ce5fe --- /dev/null +++ b/week1/homework/answers.txt @@ -0,0 +1,16 @@ +Please read: +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 an instance of a class. For example: “Back in Black” could be an object of the class “albums” + +2. What is a variable? A variable is a reference to an object and holds values. + +3. What is the difference between an object and a class? An object is an individual instance of a class. Objects are the data members of classes. Objects are also referred to as class instances. + +4. What is a String? Strings are sequence of characters stored in a variable. Strings can be printable characters or binary data. + +5. What are three messages that I can send to a string object? Hint: think methods: split, chomp and swapcase. + +6. What are two ways of defining a String literal? Bonus: What is the difference between them? +You can define them using single or double quotes. Double quotes gives you a lot more options for using escape sequences diff --git a/week1/homework/strings_and_rspec_spec.rb b/week1/homework/strings_and_rspec_spec.rb index ea79e4c..adc5e03 100644 --- a/week1/homework/strings_and_rspec_spec.rb +++ b/week1/homework/strings_and_rspec_spec.rb @@ -13,13 +13,19 @@ @my_string = "Renée is a fun teacher. Ruby is a really cool programming language" end it "should be able to count the charaters" + @my_string.count + # ruby count string characters it "should be able to split on the . charater" do + # ruby split code + # + result = @my_string.split(.) pending - result = #do 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"))' + # encoding string + @my_string.force_decoding("UTF-8").valid_encoding? end end end From 972a739fcb83bfa005a049c3cc20b011ae58ecb1 Mon Sep 17 00:00:00 2001 From: Jack Howland Date: Thu, 23 Jan 2014 17:39:16 -0800 Subject: [PATCH 2/7] homework - week 2 --- week1/homework/.strings_and_rspec_spec.rb.un~ | Bin 0 -> 18660 bytes week1/homework/lor | 4 ++++ week1/homework/strings_and_rspec_spec.rb | 19 +++++++++------- week2/homework/.SimonSays.rb.un~ | Bin 0 -> 2327 bytes week2/homework/.simon_says.rb.un~ | Bin 0 -> 34050 bytes week2/homework/.simon_says_spec.rb.un~ | Bin 0 -> 17803 bytes week2/homework/simon_says.rb | 21 ++++++++++++++++++ week2/homework/simon_says_spec.rb | 5 +++-- 8 files changed, 39 insertions(+), 10 deletions(-) create mode 100644 week1/homework/.strings_and_rspec_spec.rb.un~ create mode 100644 week1/homework/lor create mode 100644 week2/homework/.SimonSays.rb.un~ create mode 100644 week2/homework/.simon_says.rb.un~ create mode 100644 week2/homework/.simon_says_spec.rb.un~ create mode 100644 week2/homework/simon_says.rb diff --git a/week1/homework/.strings_and_rspec_spec.rb.un~ b/week1/homework/.strings_and_rspec_spec.rb.un~ new file mode 100644 index 0000000000000000000000000000000000000000..585e4e737e429d8fbe3c3c7c82c9043b75add641 GIT binary patch literal 18660 zcmeI4%WoV-5QjI8Ut8t_o60@=pgd~yyiN}qH7n~ciHoN2OO8a7W9LXRg zasVN22*Trp#080nBOKr#h=h=G+yjpj$_;S=4jiCuF?8rz5P_@=iJ1T`A=Kt)~My?k6>* zK(QPIjmYF3^YfvpoNtCE>X>S0s~wrB9vaIZ`16lkvPki{y`(I_i|;&w1Bw)0kQ74t zy+yhwMv7=UNNPxd=Ez7yTb2$UU`>*;03>dTDI8FE@Pee22baJ0;}P%{>py6G78KH9*$Pmto>Q$Y~6YmO{PT8d;Lpp36r!H$xJ7bJzq4t%l*Dxd5M$R_u- zwXo3+P1x#2+a^xJc~k2+tiU+!H5`b6)gDuopG`0dF416dt@FDOvCi#|hD!pI|iO0uQVLuXW%E zc9^9oJ2*j9h}|D)fj6JT&Y=UUIj?oV2y__9DmpkpRI<<=NSIEL*uex@V46XA-Kds;4(4(!Aa@6; z(qfN@TB5b>(?V_fPEx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l`8 z>xdi;y1KRyT;DeCfs$%B@EKA3itYXzBb&Ww*O(kueD&)B0Q-({5SV-eF&Hymh~R1h za3)oq+efFD72xrMg}B!I!kn(20_hs#7XVWyhjYARBD0LXnYY*0m9bAfi3g+?XE;wRva84AGWT1jefF~?8&OTVd8PBoXmotm+M=~m+!2m_lD#J5<7?Sx^tr9oY$ z2Bq7KXAlf(MiAd(9W^sK$@t=)g~+A3hjJfsMpJB>%MgBPz<3toueYQpPa;x%0^ zf{xD~@1>K^Ls6~X;&NxLHQ!xY>dg0w$I5pmd}cDl X1Jw|VCtCM+7gzS5Tga1de|_OgpWvw~ literal 0 HcmV?d00001 diff --git a/week2/homework/.simon_says_spec.rb.un~ b/week2/homework/.simon_says_spec.rb.un~ new file mode 100644 index 0000000000000000000000000000000000000000..b1419485267e2aa39a0a88316258ba4e6d059f98 GIT binary patch literal 17803 zcmeI4%WoV-5QjImH+JGjl1=;w5Yp`W70H-5u@Qx0U6wPj1b>f92kt+pqt4y>j2b_~oq=vtO?cUOH4L z6i!o_tog0=X0Ya)^5tMN3NKf8T4hso(Ksi)jG`Xf09!tv8Gb z!u7^h%{OTTH5Kzx5Vp^mRqSa6QD}mesRi}A-}J+_X>U}+?C8bN-!}72zgjcZwP>qt zHlx~B!*88R+_eih-4PnN4nRiuf5hv28@p@&?j7K2#d;5rJ}3WS(0`T+_W~CJ#4NUI zuk&4*L%=}X1K|2do|dQ}1PmAw9&=?6_QuC9Py@dtTogIDC!P&{7@|cGSJF`LxQbb9 z)x`C>9*8B-3fJ*8InE+`ElSvd)sWH*99>ja2C>^Db{{jlVs}&)cJ_y50LSx@2s#7q z&f=U`EMcpr4)8g5fcjtuqj^WUL~&= zos=Gg`o+ziYpr%O2;Vg4&4%A-MCBxqgW9Ol6GYJkj$oUk2rJkWqIjAq4rYE0Cz4oj zJfm3m>rvC6zff&7PSJF7!VkR0l!jmlempoke#$adn#9j%enbD3-??sn;Dt8_B4C*& zR*s*T#a2!H-erCVVtz=C#QZ%eFUTBLdVm@a$k^scDa%-C5~&aLc!$hK%nwpUJqrXj zJc1>vfE!L=aje7=wrXPap=O0#RLl=n!x+_GT|IwxacMaj$3Up0^Z`9iVX@5-Q*N0BViG2 zj;RB{4NrkQ=jNPDS;k7!>)c<^VNoW>;b>r$`?w8OJVBGF2999I;@F8LY}Lf>Odh+5 zbiyrL^^-lN0oH_44ImvnWe~efg14LpZ>rJA#RpuIN=2Y__>@8HHuu6enNJV2uzE`b zBteg}78g0iEVgQ*_X0cLNSvYcj(Yi#6R>zjIZ+QFF+p|`za2bS!KM(rI}C3$hKH#| zymye4C7Yh4R@W?Zxoesk*q%^|0x2-EIE-QmTea8u{&zh9_F|mY9CyLEu(spN8v~$w zQYi|oK#2_2c_fTrRS4z7Je0GQ3y%R4@Salo0xV$8V4L$xSiz-;dS9TRQ@mYDeDr~3?~F>jmh@e!<^rXm84 zj-6P;dY!U66#HQ>yJMPN4?3XYY&6jl7;!#}b33twt=fBVB#V;pDUV+dLcfMDC6hNxhE6F{5dm4boO4F8inW?(j^xo) zOOw{(rAa+YTfnQL)B{V$PZ`8+llYbL_>E@4G+WmVM$<|!@N>+RLF_h(*?1naqF&?z zHZw{ea6`!DHx(}NRF<*QBvwHK#NKMV#(dQ7EI>YZAFjy?zJBk&hPk@H_2uP!c3T k4{KvwRtY0m6{7bt(<{Y(hp4IPWp4x14@Bcff?q%V8<@EBG5`Po literal 0 HcmV?d00001 diff --git a/week2/homework/simon_says.rb b/week2/homework/simon_says.rb new file mode 100644 index 0000000..547a418 --- /dev/null +++ b/week2/homework/simon_says.rb @@ -0,0 +1,21 @@ +module SimonSays + def echo(simon) + simon + end + + def shout(simon) + simon.upcase + end + + def start_of_word(simon,last) + simon[0...last] + end + + def first_word(simon) + simon.split.first + end + + def repeat(simon,last) + last.times.collect { simon }.join(' ') + end +end diff --git a/week2/homework/simon_says_spec.rb b/week2/homework/simon_says_spec.rb index 7f329e5..25f697c 100644 --- a/week2/homework/simon_says_spec.rb +++ b/week2/homework/simon_says_spec.rb @@ -2,8 +2,9 @@ require "./simon_says.rb" describe SimonSays do - include SimonSays # Hint: Inclusion is different than SimonSays.new (read about modules) - + include SimonSays + +# include SimonSays # Hint: Inclusion is different than SimonSays.new (read about modules) # Hint: We are just calling methods, we are not passing a message to a SimonSays object. it "should echo hello" do echo("hello").should == "hello" From fa620bdb63e6c8605647234614eaa55f7c217c69 Mon Sep 17 00:00:00 2001 From: Jack Howland Date: Thu, 23 Jan 2014 17:55:58 -0800 Subject: [PATCH 3/7] adding questions for week 2 --- week2/homework/questions.txt | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/week2/homework/questions.txt b/week2/homework/questions.txt index 939e42d..c46305c 100644 --- a/week2/homework/questions.txt +++ b/week2/homework/questions.txt @@ -1,13 +1,25 @@ -Please Read The Chapters on: -Containers, Blocks, and Iterators -Sharing Functionality: Inheritance, Modules, and Mixins - 1. What is the difference between a Hash and an Array? +A hashes are more flexible as you can index them using symbols, strings and regular expressions as opposed to just integers. + + 2. When would you use an Array over a Hash and vice versa? + I would use a hash if i needed to store the list using a key word or string for each variable. An array is simpler to set up and +simply uses an integer as it's key value pair based on the order that the variables are in the array. Arrays are easier to manipulate using integers. + + + +3. What is a module? Enumerable is a built in Ruby module, what is it? A module is a collection of methods, constants and classes. +Ennumberable is a built in mixin which provides various capabilities of sorting data. + + + +4. Can you inherit more than one thing in Ruby? How could you get around this problem? Ruby is a single inheritance language. +Mixins can be used within ruby classes to get around this limitation. + -3. What is a module? Enumerable is a built in Ruby module, what is it? -4. Can you inherit more than one thing in Ruby? How could you get around this problem? +5. What is the difference between a Module and a Class? A module can't have instances. A module is a chunk of reusable +code in it's own ruby program that i can call from another program using "requires". Modules can contain functions and/or variables. +Classes are like modules with the exception that you can use them to create new instances of each other without them interfering with each other. -5. What is the difference between a Module and a Class? From 595d9c6a95ea9656083248a9f65696313d8b6a45 Mon Sep 17 00:00:00 2001 From: Jack Howland Date: Thu, 23 Jan 2014 18:39:36 -0800 Subject: [PATCH 4/7] fixing repeat method in simon_says.rb --- week1/homework/.strings_and_rspec_spec.rb.un~ | Bin 18660 -> 0 bytes week2/homework/.SimonSays.rb.un~ | Bin 2327 -> 0 bytes week2/homework/.simon_says.rb.un~ | Bin 34050 -> 0 bytes week2/homework/.simon_says_spec.rb.un~ | Bin 17803 -> 0 bytes week2/homework/lor | 0 week2/homework/simon_says.rb | 5 +++-- 6 files changed, 3 insertions(+), 2 deletions(-) delete mode 100644 week1/homework/.strings_and_rspec_spec.rb.un~ delete mode 100644 week2/homework/.SimonSays.rb.un~ delete mode 100644 week2/homework/.simon_says.rb.un~ delete mode 100644 week2/homework/.simon_says_spec.rb.un~ create mode 100644 week2/homework/lor diff --git a/week1/homework/.strings_and_rspec_spec.rb.un~ b/week1/homework/.strings_and_rspec_spec.rb.un~ deleted file mode 100644 index 585e4e737e429d8fbe3c3c7c82c9043b75add641..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 18660 zcmeI4%WoV-5QjI8Ut8t_o60@=pgd~yyiN}qH7n~ciHoN2OO8a7W9LXRg zasVN22*Trp#080nBOKr#h=h=G+yjpj$_;S=4jiCuF?8rz5P_@=iJ1T`A=Kt)~My?k6>* zK(QPIjmYF3^YfvpoNtCE>X>S0s~wrB9vaIZ`16lkvPki{y`(I_i|;&w1Bw)0kQ74t zy+yhwMv7=UNNPxd=Ez7yTb2$UU`>*;03>dTDI8FE@Pee22baJ0;}P%{>py6G78KH9*$Pmto>Q$Y~6YmO{PT8d;Lpp36r!H$xJ7bJzq4t%l*Dxd5M$R_u- zwXo3+P1x#2+a^xJc~k2+tiU+!H5`b6)gDuopG`0dF416dt@FDOvCi#|hD!pI|iO0uQVLuXW%E zc9^9oJ2*j9h}|D)fj6JT&Y=UUIj?oV2y__9DmpkpRI<<=NSIEL*uex@V46XA-Kds;4(4(!Aa@6; z(qfN@TB5b>(?V_fPExLe<>St<7xuTBky$m~_`lz6HljkQ=z2$hLr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XzBb&Ww*O(kueD&)B0Q-({5SV-eF&Hymh~R1h za3)oq+efFD72xrMg}B!I!kn(20_hs#7XVWyhjYARBD0LXnYY*0m9bAfi3g+?XE;wRva84AGWT1jefF~?8&OTVd8PBoXmotm+M=~m+!2m_lD#J5<7?Sx^tr9oY$ z2Bq7KXAlf(MiAd(9W^sK$@t=)g~+A3hjJfsMpJB>%MgBPz<3toueYQpPa;x%0^ zf{xD~@1>K^Ls6~X;&NxLHQ!xY>dg0w$I5pmd}cDl X1Jw|VCtCM+7gzS5Tga1de|_OgpWvw~ diff --git a/week2/homework/.simon_says_spec.rb.un~ b/week2/homework/.simon_says_spec.rb.un~ deleted file mode 100644 index b1419485267e2aa39a0a88316258ba4e6d059f98..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17803 zcmeI4%WoV-5QjImH+JGjl1=;w5Yp`W70H-5u@Qx0U6wPj1b>f92kt+pqt4y>j2b_~oq=vtO?cUOH4L z6i!o_tog0=X0Ya)^5tMN3NKf8T4hso(Ksi)jG`Xf09!tv8Gb z!u7^h%{OTTH5Kzx5Vp^mRqSa6QD}mesRi}A-}J+_X>U}+?C8bN-!}72zgjcZwP>qt zHlx~B!*88R+_eih-4PnN4nRiuf5hv28@p@&?j7K2#d;5rJ}3WS(0`T+_W~CJ#4NUI zuk&4*L%=}X1K|2do|dQ}1PmAw9&=?6_QuC9Py@dtTogIDC!P&{7@|cGSJF`LxQbb9 z)x`C>9*8B-3fJ*8InE+`ElSvd)sWH*99>ja2C>^Db{{jlVs}&)cJ_y50LSx@2s#7q z&f=U`EMcpr4)8g5fcjtuqj^WUL~&= zos=Gg`o+ziYpr%O2;Vg4&4%A-MCBxqgW9Ol6GYJkj$oUk2rJkWqIjAq4rYE0Cz4oj zJfm3m>rvC6zff&7PSJF7!VkR0l!jmlempoke#$adn#9j%enbD3-??sn;Dt8_B4C*& zR*s*T#a2!H-erCVVtz=C#QZ%eFUTBLdVm@a$k^scDa%-C5~&aLc!$hK%nwpUJqrXj zJc1>vfE!L=aje7=wrXPap=O0#RLl=n!x+_GT|IwxacMaj$3Up0^Z`9iVX@5-Q*N0BViG2 zj;RB{4NrkQ=jNPDS;k7!>)c<^VNoW>;b>r$`?w8OJVBGF2999I;@F8LY}Lf>Odh+5 zbiyrL^^-lN0oH_44ImvnWe~efg14LpZ>rJA#RpuIN=2Y__>@8HHuu6enNJV2uzE`b zBteg}78g0iEVgQ*_X0cLNSvYcj(Yi#6R>zjIZ+QFF+p|`za2bS!KM(rI}C3$hKH#| zymye4C7Yh4R@W?Zxoesk*q%^|0x2-EIE-QmTea8u{&zh9_F|mY9CyLEu(spN8v~$w zQYi|oK#2_2c_fTrRS4z7Je0GQ3y%R4@Salo0xV$8V4L$xSiz-;dS9TRQ@mYDeDr~3?~F>jmh@e!<^rXm84 zj-6P;dY!U66#HQ>yJMPN4?3XYY&6jl7;!#}b33twt=fBVB#V;pDUV+dLcfMDC6hNxhE6F{5dm4boO4F8inW?(j^xo) zOOw{(rAa+YTfnQL)B{V$PZ`8+llYbL_>E@4G+WmVM$<|!@N>+RLF_h(*?1naqF&?z zHZw{ea6`!DHx(}NRF<*QBvwHK#NKMV#(dQ7EI>YZAFjy?zJBk&hPk@H_2uP!c3T k4{KvwRtY0m6{7bt(<{Y(hp4IPWp4x14@Bcff?q%V8<@EBG5`Po diff --git a/week2/homework/lor b/week2/homework/lor new file mode 100644 index 0000000..e69de29 diff --git a/week2/homework/simon_says.rb b/week2/homework/simon_says.rb index 547a418..025a9f5 100644 --- a/week2/homework/simon_says.rb +++ b/week2/homework/simon_says.rb @@ -15,7 +15,8 @@ def first_word(simon) simon.split.first end - def repeat(simon,last) - last.times.collect { simon }.join(' ') + def repeat simon, n=2 + results = (simon + ' ') * n + results.chop end end From b32a8d07d8ac04309f690dabf6ecffdf029c9579 Mon Sep 17 00:00:00 2001 From: Jack Howland Date: Thu, 30 Jan 2014 19:16:46 -0800 Subject: [PATCH 5/7] week 3 homework --- week3/exercises/.book.rb.swp | Bin 0 -> 12288 bytes week3/exercises/.book.rb.un~ | Bin 0 -> 16763 bytes week3/exercises/.book_spec.rb.swp | Bin 0 -> 12288 bytes week3/exercises/.book_spec.rb.un~ | Bin 0 -> 16114 bytes week3/exercises/.human.rb.un~ | Bin 0 -> 3671 bytes week3/exercises/.monster.rb.swp | Bin 0 -> 12288 bytes week3/exercises/.monsters.rb.swp | Bin 0 -> 12288 bytes week3/exercises/.some_file.un~ | Bin 0 -> 523 bytes week3/exercises/.vampire.rb.un~ | Bin 0 -> 1870 bytes week3/exercises/.zombie.rb.un~ | Bin 0 -> 5103 bytes week3/exercises/book.rb | 24 ++++++++++++++++--- week3/exercises/book_spec.rb | 32 ++++++++++++++++++++----- week3/exercises/human.rb | 6 +++++ week3/exercises/some_file | 3 +++ week3/exercises/vampire.rb | 5 ++++ week3/exercises/zombie.rb | 8 +++++++ week3/homework/.calculator.rb.swp | Bin 0 -> 12288 bytes week3/homework/.calculator.rb.un~ | Bin 0 -> 27650 bytes week3/homework/.calculator_spec.rb.swp | Bin 0 -> 12288 bytes week3/homework/.calculator_spec.rb.un~ | Bin 0 -> 13356 bytes week3/homework/.questions.txt.un~ | Bin 0 -> 33152 bytes week3/homework/calculator.rb | 26 ++++++++++++++++++++ week3/homework/calculator_spec.rb | 2 +- week3/homework/questions.txt | 24 ++++++++++++++++--- 24 files changed, 117 insertions(+), 13 deletions(-) create mode 100644 week3/exercises/.book.rb.swp create mode 100644 week3/exercises/.book.rb.un~ create mode 100644 week3/exercises/.book_spec.rb.swp create mode 100644 week3/exercises/.book_spec.rb.un~ create mode 100644 week3/exercises/.human.rb.un~ create mode 100644 week3/exercises/.monster.rb.swp create mode 100644 week3/exercises/.monsters.rb.swp create mode 100644 week3/exercises/.some_file.un~ create mode 100644 week3/exercises/.vampire.rb.un~ create mode 100644 week3/exercises/.zombie.rb.un~ create mode 100644 week3/exercises/human.rb create mode 100644 week3/exercises/some_file create mode 100644 week3/exercises/zombie.rb create mode 100644 week3/homework/.calculator.rb.swp create mode 100644 week3/homework/.calculator.rb.un~ create mode 100644 week3/homework/.calculator_spec.rb.swp create mode 100644 week3/homework/.calculator_spec.rb.un~ create mode 100644 week3/homework/.questions.txt.un~ create mode 100644 week3/homework/calculator.rb diff --git a/week3/exercises/.book.rb.swp b/week3/exercises/.book.rb.swp new file mode 100644 index 0000000000000000000000000000000000000000..e8747d52902a259641e1847e8904dbcac2c15c14 GIT binary patch literal 12288 zcmeI2%Wl&^6o#klxv$tA+_IvIb5jeIB8BddD2s~A0*PpBPZ}$O9odeWPyvs?Wx+EP zo}}#I4a%ZBV8xPuY*&b&3UyiWkMe2avCn0`o#hFdkM3^CdZVi_E-B@IJlftL-caF@ zQnPft=9d38wwkxry6w*GR>P*DwkJOR(k1jmtMlC7o(A*BaZ;G9-E4LJU1P=_-^@%F z#<|J;AWg@OEI2V0Z_oe@oZ7&7)oHhyE^OJmE?2KSJaq;J&;Sk401eOp4bT7$&;Sjb zT?55rNxee*=jtt7tLLSKxxVB?12jMbG(ZD1Km#;D12jMbG(ZD1a0U(N2%r5gDD?)o z@Bhc||6eaEbqKzI&)^d{03X0Ucn98s8Hm7B@C2-b6>u5+M9v@JJNO0;!2x&=T)o$T zg9d1T255i=Xn+Q2fCgxQ258{_G$3M9A5P)C&2gG2&b`tZGWVt{pE2g1|5-CKHkPxCc@l#M(hx1GhE_asiD1t-* zbd-Sxq$m;;NNK2|R4EY9M-dVd1ke>xM1e#@$i%pU3cBJ+0?b~~AHJ@j8 zcHZ7=&GVOEZJ+7fE+#%a{L#YAo3FR8emwWj#aBLA{;Kxk()`<({$BiHrT_H{*RB>t z@t71Zd*s8>*gMD++_-jdS zJT2uuDGy2k#Z(X(x-u)h)mW}GmO{ID?gK?idy>ylz&Ru3Q9fs+Xd$Ht($73nRDZt| zkXGR6F~|lDNK=f60zk&_50Rmvgrp+SJ|73|A$cnHG>;vg+GxC0cEib_b+k4>DWo_* zAOa5L85~MTDgy4(?%;aOUfCJ}2PiDj#9S}PGdR;qvRc4h{$Jo)}vmCsf^bF0%KlZho?Ss$*QcPI$_=-lKInp$>q^gD3w>uG2ON_<^8a1Ri8L(wk zsmN@*ub}#FCsad@5H`Bai?@NBSz>mC+jM)cJA~Eu%4$!wXpK5T+p^j6X3q!NU<;SM zpQ$BPUGM*V-J2AP4j}}V!g^(xz%sBNX@iqcQDgs%Ni>mE1k(+V$+lf{@>DP_Rbj>H zPUoFtt>&AXjm-P*3~K8fw%PY^@`u0mP0hyX29T}6U zB~>k$YKm#1+O1(BrhbnJEC<{qK!(>lL|?{)7E+2}ddXXpo#ruXIut^q*V|letgV&Z zZf7$b*V75h;kbtS(bj;b8Iw3wfZ{(jF_s}ltt6`i;u{{~=<+oe)>@5jH=H;T2p%Ie zAo+uR0Muh8%riqn3n@jQt$S$p3Qfa64HxNQ*R4Gf8jv1$(*hu4@)pf0C0$dXof`*@ zRg6__pB&>lHI!$T( z0_{_UHd&=14H_9MY-?f6>J`aB>WG^h6v<-h*~#n`oo13W>-}H8P;yfhIm`1Kxp-jw zTw`P7LL>&Er`=?r2V|8@%rudzuJ>;bo$%o~yu&8Z2!_2?7Lv1g5g34;kzxY849v8V zycS@;sfkTjCdLB+MxshFL`+~gD#Zk3gG5%gD^p9VT7Fc&>;n%nQKo({O>X_j$r}^X ef!ZKloJpaQlp>^#DXE#tpfDs;e>A8&SN;QFc_p*} literal 0 HcmV?d00001 diff --git a/week3/exercises/.book_spec.rb.swp b/week3/exercises/.book_spec.rb.swp new file mode 100644 index 0000000000000000000000000000000000000000..050403f7900905a07a2dd302b92adeafd7aa3767 GIT binary patch literal 12288 zcmeI2&ubGw6vtn^C`hX)UgfzJdXddfYa1zuCwr(!p?VCnyRXTT%}zSAYm$roE5wTj zPkQs}zu-X+A_xi|dK2{IU*Ma~Mw4Kb9t&^blOek^?>q0ar;rJ%54U&lmfr-vE&{wb zI@*2HxDM(Yz)1Jj-R=KfJJpT#X1%dl^AjDaRrRjm-bGwSmufWF(3xS zfEW-1Vn7Ut0WomO4P=8QIOHDAlzm(+$EAg_{3?SO5CdXB42S_SAO^&M7!U(uKn#ch zF>neEs0d(l8Q?wR{{Nr;{{L|S;5+k$`OLg!o-@ywr_7MK&0Jwtm~+fo=I08)N9Hy2 zih0QxW{3E5CdXB42S_SAO^&M7!U*hHb7|v zSbX4gK)mD5Qu|q)CFI+#&XWk~0KErBcZ}-y6oum#_hwM!1&1M~DLsXLJp^M2hb~w-lrFlOfgL)r})kUP+ zTiMsNp>mss>_Decn+tf8`3rq?)nh_6Q)_1XvjJQl=VI3$z;Qg8%>k literal 0 HcmV?d00001 diff --git a/week3/exercises/.book_spec.rb.un~ b/week3/exercises/.book_spec.rb.un~ new file mode 100644 index 0000000000000000000000000000000000000000..40067edabf5112f6821cc9d98adbe6ededf739f9 GIT binary patch literal 16114 zcmeI3J8xV?6vwaMNq|5IF^|N__>l%AH((@;gQ5t&z)GaVaqLxWVs?Y=@TedP4bV{{ zq#z+t@EPd%0u*#SR|wHU;SLG@zjNo@on0lHhDkL?IzD^v%cw0b{QhNG$upVG%q$fxDU2b!1 zj=Azc*eFe}!O3Tu8VgcoBC84Mvnf&-k$w!MQ=#42a#k)&Yo$?6XOn1Qf7t;$F9JpG@2fkKhD7H44gP~LQdxi?@9yn++*^(D~LJc{{YSGN4afy>opy1 z(o`%P1d@=|#Q#dlADo_ko7CdE(*^8<0U7V3H44+lC`{8*o|Y*QmdnqFgmQsp ztIRU_d0KKs!P**zMLq4;)MQ2JRn-UMMbeH7D^E+VC{}N#teBse&YqDEOljWmG$XOu z4@J?H>nhD9E^A>q%G5_oT0~*%#Z@nD?xdg1e}y$E$!TJJdziJYQ1qo>I;JAJa}XAE z!7~<8WT&!PG_K!*6NPr>AA z$rXiZ;94k(BK;T$QbmEr5z-FQMqvdNDamO`1GpeBw{De${3cj0r?6OE zhWNF>nrm)4@RarT#yjn>5r!|TxQgTZ8c`O8o{_9k3dIky~(b{xgTY_Wq4-XKVeS8y0F6Mv#ExcM@(u4e|ogGm)MQP{pKV4g2r52Sv^nyzBAD4Vl{i#* z@_Zj`3qz8S)x_{CV>nea^v7tO;XLd5k-uh+%lcG@j2NbHv`Sj4CMn5j`n`DlyVse! Sb3A`vj$!5b7guim`OSa!VjU|0 literal 0 HcmV?d00001 diff --git a/week3/exercises/.human.rb.un~ b/week3/exercises/.human.rb.un~ new file mode 100644 index 0000000000000000000000000000000000000000..614568c65c5efd168cb566facc95a55bce24286e GIT binary patch literal 3671 zcmeH~Jxc>Y5QaCG_<^>Oq>5`HXD142t%Qh$LNK=BNDe(nPRxgmRlvetuoA39(ALsY z5Ugx0Y=j`uA0U>Z^UmFbiv+RAb^F3(voo8`F%L7lx9!!>OaAI!Pg$2IoAWbIg}dw9 zuZP3rQD*)A<@xluQ2Lm?xyYVn-jq_~WNEEEzfx;gUA^Jd-Rjn^=kJhzjBJW5K{iPS zVH8uvZf`k-sHMt}h?1;e;7^2LtZ$M^%FK+T&p@&JI>$Ja`pnYyNIen`V@g^N_!$*@ zXhB~LEZIUUV#d*BfPgMWfnw(<(CJFeX*Ts*yYBcQF%U{coKK@u%2U_pBo0U6>sI1DCaAx;sd6~>eZIwk%KNctEW?ta^AxaEdh zb6Vbkt8E`AW4VQ+(GF`3t8spc02B}>;4l!8g*ZjG4|`ax35MLiAYwHG3m+9g4a7LP z4eU)27yg2n4j~S!KcJF(DK-U0)TF6DWFvMFx`Eq?v_n4E_*w}MX6y-@X0+DuhyaK< eUNlV8L=s{ZK?^P@R&eqOG--Q7-v#rX_p2XIFqs$t literal 0 HcmV?d00001 diff --git a/week3/exercises/.monster.rb.swp b/week3/exercises/.monster.rb.swp new file mode 100644 index 0000000000000000000000000000000000000000..0d5d72004f4a6ee7274697eec2f93850fa813aad GIT binary patch literal 12288 zcmeI&ziSjh6bJAZyDj{Y2-f2nNW|s#ei1bgut<~QEJD;mB+TtT&moi9IJ0|+7Rg_c zB7cvSX>0^-g9!N(EPZp?1QCLyun2qy-p%gJ+c&eHZnzzFUak$*(Pf-##QWlo$espW!~y% zyvIH_fkU=kx*&6HKf1IUCLjQTs|nnsey`h!&pc?|S9j-LT+4IrJaL zgTMU$e}4Y|d7J2)#3zX(iCu|Wq9-vgF)Q&)l7C2imG~kNYkZbKg8&2|009U<00Izz z00bZa0SNp*0d_?~iTqNMJhMCwYDL8^-WJ-8*~gLQDh^I;?bz#)v8FN{CnvRy6Rymw z+Bm6Y~7NHlEc&JBwQ^HmjH^2Re;=vd2 z;K2tF#0T);NfB>?-aJ|#px6fx{7#xeW0Kl}m*Q{W!(?}6cE7*R?q$gY`Q=*`?^3qR z&`vUT0nX^XLSy*lSk|E*Q>m*>jG(v?D1>5!|5(;vGF=0e4-%~jK&SCerf zOfg?5=ek0ymU3cUm{3|_bCHfM#%$IE6E8;tWPl7D$iOr!6$^Q{_T1FfdX zWPl8i0Wv@a$N(8217v^<9Buc{{YAOmE843GgbKnBPF z86X2>fDDjH` z*We|120Gw2*qmnU2lx)Yf_LB*cnThXyPygdK>?fwzmVw*_&CV--esgl2FL&zAOmE8 z43GgbKnBRbe{A3pJ9<@#mh~2{d3pR^OI0ik52TWb6#dh6fALPy&v?EJh3i7C8vaTK zlN&s4VVkjATla0+Y+?g*B6Yky8tX7gP0W=WZ*paYTNCq0xD)<$r2{|1W_LC#d-L<& zL$*6lc~TxL)tWG4G6XUa)@8Jz;YrxWK|knFl*FXNNovA~u2#*x(-bGA>1y3@_iTue zcVx0{zi#b@Sc*bcCuF~?OrF=R_?2kWgc~;!Bg5x z>%>Bu{iS0H;mP3cLl1n6Y*%$^T+yT2N8f--8b!T-nRWD~9FuWB$?oYWkYhCN(z@W) GSJ-c&=su7D literal 0 HcmV?d00001 diff --git a/week3/exercises/.some_file.un~ b/week3/exercises/.some_file.un~ new file mode 100644 index 0000000000000000000000000000000000000000..e28d5e5e3e73680c33819d937c24350d07b81cb8 GIT binary patch literal 523 zcmWH`%$*;a=aT=Ffk~Y0N77XnCBC)nby~lt9$mOYOI)yXR^daL)eSj+_H1xtU|?Vd zVr0MwQ2SRf+t7a;N|Bup__@IMe>7>%NQltWnv0HfnCG&;UYpcw^@ JFVn{7s{sEjA&~$8 literal 0 HcmV?d00001 diff --git a/week3/exercises/.vampire.rb.un~ b/week3/exercises/.vampire.rb.un~ new file mode 100644 index 0000000000000000000000000000000000000000..efb1a03aa2671f9fb52e3ac4112bad4f11343512 GIT binary patch literal 1870 zcmWH`%$*;a=aT=Ffr;5?`t?l#yaDqr-m*E-=luNslUweOHwr)4a{Kz_%z2v<7#JA1 zftW=B2!J#P5Q6|C5VL?;5E{e=^Mf8f?`8qXGBU(pfGS{u(jW>X#R|k=#s7f-ECP}l z1vCf&V05T~ql1Crs|3(|P_TpIkPV2zambmPmtxuojw%qJ8Hiy36m9H4EC>=9jVe$m z&=LTn$^<#8Ktaz5#9TlOjw(P!C4PTg8(SLK^j3>ax{)Xfk0CLjN=;QI0nTRsCb3NF{^?CB0nPMMUbmt kc^AYUjVo{{(2@YgRTns}7$JEKmg_+A1<#MBjn7vB06Nf3?EnA( literal 0 HcmV?d00001 diff --git a/week3/exercises/.zombie.rb.un~ b/week3/exercises/.zombie.rb.un~ new file mode 100644 index 0000000000000000000000000000000000000000..94062104d5db0e8baa74ddcb6b1109a0c098c9fa GIT binary patch literal 5103 zcmeI$yGjE=6b9hU#d~jJys%vg3#;G@_y7`6(k%fOT`&oW(ZVjEZ(t{AV`Zmc5ud^b zunAFof@lOm&p&(4GA2v5ajfRRWHvLC>~KD2_Oct)u6OENjaMh_eKju5FYk^XE1p+y z&rZ9!hnuVI&F1rPaPM_D)*Z*0rLxxYo5w-R_gem8wH=)JZn0ji`FmdbAgJ#bX+(<3 z4A%=(BT!3m%DtD*EJkG9A6t=t5EPO+f=~7|TGp*Y7KilrzZFSwJyGB})Yi zY1fU~(WWp|3w?<~ft5N66vsLl{t>@ap+F;EX|?s=Wq{UKMS-S6P+(#~V)-KRS(icq zN)LL&v0%eD^ys9&2&oU_(64@JNhuRXgGk>MDKp_@AQ94pU76P<&;TnTE8HSVMvT^k z_%R7_l`pOFS5`KJ*|auIS*X@fONzO}B*PUpjJ-KxLfLg?mf*B|sbs@=okY0IgmJgG zEC?}dy%Jb_R#38GyiO7^Js$fcd~BuLdwvP+C4@;$MRJhLdhYbIdpTa)x>DX0FtEyZr%amGn9Q literal 0 HcmV?d00001 diff --git a/week3/exercises/book.rb b/week3/exercises/book.rb index c13e4d4..614350e 100644 --- a/week3/exercises/book.rb +++ b/week3/exercises/book.rb @@ -1,7 +1,25 @@ +$global_hello = "hi there" + +module Library + class Book - def pages - + attr_accessor :pages, :title + + @@library_count = 0 + + def self.library_count + @@library_count end + + def initialize pages, title="N/A" + @pages = pages + @title = title + @@library_count += 1 + end + -end \ No newline at end of file + def happy + $global_hello = "hello" + "There are #{@pages} happy pages in the book" + end diff --git a/week3/exercises/book_spec.rb b/week3/exercises/book_spec.rb index 72bc203..ea20250 100644 --- a/week3/exercises/book_spec.rb +++ b/week3/exercises/book_spec.rb @@ -1,10 +1,30 @@ require './book.rb' describe Book do - - it "should have a pages" do - book = Book.new - book.should respond_to "pages" - end -end \ No newline at end of file + 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 + Book.library_count.should eq 542 + end + end + + context "#pages" do + it "should have a pages" do + @book.should respond_to "pages" + end + + it "should allow us to get the number of pages" do + @book.pages.should eq 542 + end + end + + context "#title" do + it "should let us read the title" do + @book.title.should eq "Programming Ruby" + end + end +end diff --git a/week3/exercises/human.rb b/week3/exercises/human.rb new file mode 100644 index 0000000..ccc32e5 --- /dev/null +++ b/week3/exercises/human.rb @@ -0,0 +1,6 @@ +require 'named_thing' + +class Human + include NamedThing + include OtherThing +end diff --git a/week3/exercises/some_file b/week3/exercises/some_file new file mode 100644 index 0000000..2224a72 --- /dev/null +++ b/week3/exercises/some_file @@ -0,0 +1,3 @@ +3 4 +5 6 +7 8 diff --git a/week3/exercises/vampire.rb b/week3/exercises/vampire.rb index 764adf6..6464111 100644 --- a/week3/exercises/vampire.rb +++ b/week3/exercises/vampire.rb @@ -3,4 +3,9 @@ class Vampire < Monster def initialize(noc=true, legs=2, name ="Vampire", vul=[:garlic, :sunlight], dangers=[:bites]) super(noc,legs,name,vul,dangers) end + + def bite! human + + end + end diff --git a/week3/exercises/zombie.rb b/week3/exercises/zombie.rb new file mode 100644 index 0000000..131600d --- /dev/null +++ b/week3/exercises/zombie.rb @@ -0,0 +1,8 @@ +require 'named_thing' +class Zombie + include NamedThing + + def say_name + "uuurrrgggghhhh #{@name}" + end +end diff --git a/week3/homework/.calculator.rb.swp b/week3/homework/.calculator.rb.swp new file mode 100644 index 0000000000000000000000000000000000000000..9225e78caff7e766b580fb89ef81ea5c2414b07e GIT binary patch literal 12288 zcmeI2yKdA#6ow~IheRMzP#rFjU=zmPi^3*SL_tN7CgM^c5zX3T#jJP6vd7w8X%(I# z)RepdqT>yC0-%5jB=QQJ@p=P7ir5zPkMwEmbI#1Mzs~Xu!Y2>+>7MKf9_vE9U;Td2 zpKXXor$S8ZaNCFfHul5*cCXXjY0Jz;Dm%CQ*l!p_nJUZRpc+h{rpD=_6SjN7SnFXo zII<%>w#6{uU7{*e&K9y5oVyG{_8#ee}AfB_hQ0T_S*7=Qs7fB_hQfinZz@TV$~HrkKHP0S&p zQI)wg&!%*{Ev305ojp{Xh?lNQC{Yoad4u_$16Ar)OHcB8ql9uhCLh}(ALF2Z2I8TL z>7l7crA+w5y3*UwdwHBqnFHcQgIa%nqiZq2=w7coEM9w-sOYg51 vjhYy3?onDN=1aATjwrS?OJ{YoUPyby=X~e=%W6b*sSx$ydwOtoyk7hSf8?3D literal 0 HcmV?d00001 diff --git a/week3/homework/.calculator.rb.un~ b/week3/homework/.calculator.rb.un~ new file mode 100644 index 0000000000000000000000000000000000000000..c4928aa3266b13255f1f6c9d171278d030d0dec9 GIT binary patch literal 27650 zcmeI*O>9(E6u|KTTG|4Y^8F1D1c6d3Rr$8WL^eiQI7Sm?(F~=8YClM4n$QFj(S^pu zL`_V@jXM|U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FIZ~b2g*W~BJvzq3r>s9RP zIWt{X?Vw3=gKG26;$pRmoNGW#&M_wV+-Pju zDHC_DL|A7utkWxDe6dc6p!R4`yF^gC7j*3S3vSEA>`NtT%G68zhNS74f%QDy46SEb ze95w8WOn?PAIqlinkred^egMjy-C6d@S_(%Va{XKsW?WhpfDyeS#!+H4`q6nVmiM> z4&Bq;Cu3S7UAXp}xPFSIpdv|8J8Z~=GSyoch=~_i6mF!jP?G%Pyx_bF1nU)3s3vR& znI8w;%5BGRz8#%`y3Ve%=1qKLb|Z3=#O>--{R-0l#Ey%Mz=y@nI;s$_;D4{gf&Nb7 zXOgffGF?%VJk`YBP_Uu*hzbJL@uRg%sDFm8M;@BueYc@D_d3NmP;F?t12e-dL^QfV z({@<7Z5uUX&R8%m4*e`)g67csA2unv^k-tIDs-dnzVY>PkIlMZ*mfbIy;wTo`#wwL zD&!nM78OB++FEh_DvN_SLzXFFYN9GTE=gQz@ycx+3M%9p5 gDpEf>QRpDjuvzb+n#hf|k5;qh$kBS7s-G2q1J3dktN;K2 literal 0 HcmV?d00001 diff --git a/week3/homework/.calculator_spec.rb.un~ b/week3/homework/.calculator_spec.rb.un~ new file mode 100644 index 0000000000000000000000000000000000000000..010d1ab89e3b2a36cc01dc38018499fe7cd4c78e GIT binary patch literal 13356 zcmeI(%TE(g6bA4q;sf6g%B!GIM8HRhG3;F+iHR!{S-5E`cG1{EoXEcZ@D{p)n?IT;R^f{idh4A2OYbiO1Es$uK9-PENjGFP)j*F4P(iE-lS1e~P*a zQy=f#y>|b}npXmI$9jRIbW++ zOIK_0Ql(LyDwpTaUpQATPv4qZtkf4*>XjSIanU^^=e8c%kGMSs_N^_t_~qgEZagX% zm7n6TZge$w$s(Je!!C%x$={!t4l2)9z(;5AYT zM7Io)p75mMw_Xv2;5O>y&65JrEkmAD-ZOBiBb?w%PHLrX&>E+%Ass!$Iq5mGFI+_vdOPXxtqWPZY@tx} zN~ifE>$2sT*UY>NA(%khMa=@%rX~fVTZS+v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0 -> 12288 bytes week4/.code_timer_spec.rb.un~ | Bin 0 -> 2358 bytes week4/class_materials/.code_timer.rb.swp | Bin 0 -> 12288 bytes week4/class_materials/.code_timer.rb.un~ | Bin 0 -> 8829 bytes week4/class_materials/.code_timer_spec.rb.swp | Bin 0 -> 12288 bytes week4/class_materials/.code_timer_spec.rb.un~ | Bin 0 -> 26256 bytes week4/class_materials/code_timer.rb | 9 +++++ week4/class_materials/code_timer_spec.rb | 31 ++++++++++++++++++ week4/homework/.questions.txt.un~ | Bin 0 -> 8772 bytes week4/homework/.worker.rb.un~ | Bin 0 -> 7178 bytes week4/homework/jack | 1 + week4/homework/questions.txt | 23 ++++++++++++- week4/homework/worker.rb | 7 ++++ 13 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 week3/exercises/.odd_number.rb.swp create mode 100644 week4/.code_timer_spec.rb.un~ create mode 100644 week4/class_materials/.code_timer.rb.swp create mode 100644 week4/class_materials/.code_timer.rb.un~ create mode 100644 week4/class_materials/.code_timer_spec.rb.swp create mode 100644 week4/class_materials/.code_timer_spec.rb.un~ create mode 100644 week4/class_materials/code_timer.rb create mode 100644 week4/class_materials/code_timer_spec.rb create mode 100644 week4/homework/.questions.txt.un~ create mode 100644 week4/homework/.worker.rb.un~ create mode 100644 week4/homework/jack create mode 100644 week4/homework/worker.rb diff --git a/week3/exercises/.odd_number.rb.swp b/week3/exercises/.odd_number.rb.swp new file mode 100644 index 0000000000000000000000000000000000000000..0ea535d751c162c7dec42109a3bcf11119956312 GIT binary patch literal 12288 zcmeI&Jxjwt7zgmHvr^G7aO$E6c_->1xH?opsE#Gcop3ZJk{4SY6ddZLU&dW0zk}aG zH&>se7YCt27a{OJ`1j$i&mFzr7MjpHJ?!xv!(%j-tB>jEela#qhki5vtM;s2-*enO z+lbRBh-bFmRtK6<9OSuqQij)ODk)^7s@l` ziSkH!piC(B-WJ{+KN$iLfB*y_009U<00Izz00bcLKLWBE2|a>yt_$ah91X65_*jUe z=?n0*uz5f$rR3Y(-lAS1&v{-(QL~TJ&>j1{?$k{xQH2U(btCmMtKYuoKZmn#=~z?U literal 0 HcmV?d00001 diff --git a/week4/.code_timer_spec.rb.un~ b/week4/.code_timer_spec.rb.un~ new file mode 100644 index 0000000000000000000000000000000000000000..809dd2d32c856a7f1cbace20eec9aa4d1b091eb0 GIT binary patch literal 2358 zcmeH|%}T>S5XUEJYU>AhtRR6U3et&LYR6KJ4KAU1fe&!FJVizhD@LC_cI zP4Mi&gCZUZB7)#WbpD%N*#~HDJMhm;W@nQyzYMz{56<_Jt@M@L=9PaOY;W9u_HI@` z#*?FypZBNho&NJ<<@=>stDh3lGD};71BX>r33x5)OxN!`tUA$sC88(^2m9tq7s2NR8ngs z;UhNj;zz*Sv701(S&chuv+n@UV%vld=!>ic78+j_B1%HV3Tz}%_AqdplM!DmE8U5* zJhQqmSz$yleBfn{lpa3)9YBU!9|?;IT`1ES)7Zp>_M4b|A>yG34tr_d4@H(IBF!^# zkcLqp!c>i#IcE4+@WX84V6_a2uvlgKuynebm{uqs#sY*nran_AOHafKmY;|fB*y_0D=D@P@OjD znvXJ9A7{Sq8$bGbhzcm zEFX$3QC4A5nPg_^2l1u27^PArmnLUsMf-aJCllEdrBppr9q5PjB5S)u=JmbUCVD{rPeK z@rQ%2t1k{e?|j?ezt>rrK6>}$%lggLy>{vM(W5NOrYTP1O(SpC^On+J?alzNr^WQd~iS0Wn^uTp*X8K`w{?I}l=9bS=N4@KFRUJn@bz(Bj? zoX(_8pWC9nM;}#*b#@p|_1R`Xh(8SyhxA*fKp*}(b12|viHR)4 z3}O1NOk=}45vGcBd8_WX6fPXKAuwXnc{-96S%?|6Zgs$lmY{4i_X>aZP&@0+bgeyZF5WfJRNhG z8v@4g-n8LDR-)BH_fqLfy~C08bMHANW$18Zkbw|5rEM0n5xuT;Z(mlc@sk%ayo$CN zRLlzjBXmo2q!W@X#0;Ukt90el>6T7AAzjO#kzmc3MAxBHkjXD@LV)2fetQx zmX)|nW}-BUxF$W9*Fxu#SqO4yQPOQaNr)OnS`$4jj|I+xSr2eP@nIlgk%XurST{zU zgcZf|R@j8^v{@By$%;(;mngC-W96yrmSS6&NU??E?0K5cMP1M%0lc+6~GBGg(q^iJZ`Ok$~b?o$fr@&G+Rz3n^ zhlTP*U`Ap>06yzO=+yz6h1ulS3 zmxTBL-hxx`8oUB0AP4ur0BnFJxCmB21C%+=p+}C)2G{@_U;}J`4X^<=zy{a=8~CRU z$P8b9L}W({L{V-s?G%T(Nn?`7xWO0qqQrrnI)^Tbq6&y$AIpCN#$^I&6{L_Q9cl3O5gCLpy~wVQVkTr)?+5VqZyZ6dG^#%7(SLWy5*i zdO*T6N`ptWcv=}*=2^rkS0K-#vLu*ohNUCiiI>(wEkxZ}l_8czq>@nndehRKlE)@d MlGdHtwfc4O6XWdGQvd(} literal 0 HcmV?d00001 diff --git a/week4/class_materials/.code_timer_spec.rb.un~ b/week4/class_materials/.code_timer_spec.rb.un~ new file mode 100644 index 0000000000000000000000000000000000000000..1da7ce3b24b251b093f10383a44adc31015fdbc7 GIT binary patch literal 26256 zcmeI5%a2r55QiIv21XG?))SD##Eif+GD*{oGu>g0ZhZX% z#swQ!7#|DYiHUoO(YSMIVu(zFudr3?JNMRf^$pYXrgl}y@!YqJTvV|A_iKR2V2y;+idU5}bgricq zyH)PLM#=+HHb?=*mQ3tqYqoxR?s9#8tS$eYxgal(Tub!0WJrn{B!ix+;a&^9ePw#X z@~IC?8Gs(NR+&aZ5_;P>7ruuIo+k7TT6##2@6mtudZY5(wv0Dsv#r7*L0IMQ3j;6T zh-86OmGG(s>BPN|J|Z88Lskk*U|G%U!a(+*l=Zw0OsL>#f@#WP!t0P91Jefl>|*2G ztJ(3aJ>SvM4oVD=Y7k_gOb!>+R2HvVsGYFX=oN9SNBO`Mz2H8a(FnAfW%cH4;d9WU zi&cXpw@9ID&{J8wYN2<=(!+6J^_UcVZnwDHTss?CxYX)2W-}tqtks#%h&D&M102+r z1~fT_D7d*z^qh#`YC`d4OHqArlY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rnVAnfU0L}s4DhzOBOkzW=D&krTtoN*=Aw4^aNDl+6 znu3#*YvwJIDQRskoq?*Zt#a{zk1K%qpcFOmbDLz*x2h6ewIKi4A}8yw@%u_Bb+PSM6>+TvQ_td08B=dJ3Y^2HJ%9riQ}~EB5y902*5}rzke*O6ErF-L5`3JY z_r%KvU#SD-m=rZI(?utX?oyTTss(M&mTJ(d{IJ&W$L3hl1%V>wzFj zlQpTqbg!i!5RFSw179FhHQZ}K_Ral~jWk>BY;vSntpm}7X&LxH7Rx|J6u(13_H9Bo zl+W$TURKJ1LFZ}H8px4Fi4f9=;&(W`cwoJCFtRAfkI^Ug&7#0+k}C^?BYzxO6jj8v zz8|}x?%p8CJYyOIHN_mUzY)ggP)Kb^UbZUl6U$zv^J%agF--s&vw~z1$Ey-vwO|@a zn5sD@O=sz&k^9MX@oQ`*shmG-m-aP}wJz2s$HsMkGw_a@rUI5kXT%{!6u(1(c{0IV zox`NNBO9qO_olSvX<)WH=WA2V*45FmbIsYA`FguE->i)vnpBdId)BlRs)RKWqZm>A z4u#}78>6s1y7UA{%ACNIGrIOu?WUx8i{)3|&c6uE&N-uB1i837P=fY3DQaNn;$+bS zs}f$dpnkKATIIKy6tFyR8UZrC7O^B`MDaTmOdnWG>VKNK%%2_Mw=PS+m7h(Fk9Qw1 zfZCL4B}DO4ei<{OQbceyp_s4otjRk@91ViHuvdP-06fP`i$Di?(wcz_5nN4h{gRw+ zZH|ka7RY$+gTC>w40>kA=6t8Q^rOMqw-Ka0@IBtkjdnipF7QVcJO#Mapc;q8~+2Fz@jVw literal 0 HcmV?d00001 diff --git a/week4/class_materials/code_timer.rb b/week4/class_materials/code_timer.rb new file mode 100644 index 0000000..3403518 --- /dev/null +++ b/week4/class_materials/code_timer.rb @@ -0,0 +1,9 @@ +class CodeTimer + + def self.time_code n=1 + start = Time.now + n.times {yield} + Time.now - start + end + +end diff --git a/week4/class_materials/code_timer_spec.rb b/week4/class_materials/code_timer_spec.rb new file mode 100644 index 0000000..e2701db --- /dev/null +++ b/week4/class_materials/code_timer_spec.rb @@ -0,0 +1,31 @@ +require './code_timer' + +describe CodeTimer do + + it "should run our code" do + + flag = false + CodeTimer.time_code do + flag = true + end + flag.should be_true + end + + it "should time our code" do + Time.stub(:now).and_return(0,3) + time = CodeTimer.time_code do + end + time.should be_within(0.1).of(3.0) + + end + + it "should run our code multiple times" do + count = 0 + CodeTimer.time_code 100 do + count += 1 + puts count + end + count.should eq 100 + end + +end diff --git a/week4/homework/.questions.txt.un~ b/week4/homework/.questions.txt.un~ new file mode 100644 index 0000000000000000000000000000000000000000..5551ae3b6e60d9badeee9f3dff03e3123afa023c GIT binary patch literal 8772 zcmeI1&u`cFjMBlpxIc;E59c!H2PO;7Wcp2mJ&Yn=C)_h#nh z+jRBGH~A&C5e#P!AN+9bz_TB({`uyj;#yqgAhx6C{z0B2Y$xFT&x; zA_^`Q_6|O^$s+Uz*bZV+Q*E))?c3%7d3c2W;^}?@cT_uzsjJ$g+Ip?6sdhQZGDSC3 zk;Nx!q!mRbtqCh5iD|XF)PJ(Bzu&6XSOB}&L|7as6`0L02n4~YctQMSFNlwMw*73A zY)JL7)i2MTJ#%{YtC`Okqo&(YqgACcNTD)_KoP44>&cTt5S)t1J-5jrm64`GZfaqH z7I{;xtF`x6ekcM~r1d-;9wnmSQeki6I~ygc>LE5kIX^o{SKL@G zr3E(;RMDkI7L{l%ygPdS<~;qx@DfO>vSXI-xi%DxTo?5t|4{De#gCL z9aRKmTWiE)lCZcM8PodPm?TSpX}Bfb0f0dtM+9g{Un37nBH?OeQ1@+6QcnpJnns`0 z(t*c*#?CqE3E`^{u%hM~d6W_fS0khR$wn#QFrSSHSWNG&`XOlJ`HZWA;eL1<6S7Id zzr8d9jP!T#y8um|^hZrZ#Hkq6FLpiw6nZ%3=C-Xg4m?sC<(MfgIXmC*qk+|*K_>{ zUhUnJ;K`GERB$Vzg1-OD%sM8ERO$3I52mxs&L+eA@n$#Mg?npH=eyU|-CU<075yHXCwc zMA|WFC22>c5%j*9RyMa&;cV61e#Kdda=+8RoT6#`l+cg#1F7HR479Sdca@`Lc23D> zlX?u5L`T9eRG8UKh4VB0d9KJI6)tD=Q&PWo8E9qoGYV&Z!&T(t!3&unVcbWK%RplC zX^GVf)AS${1dzZ~8`wr&aWQ37nh!sHf`O#w(-Nx}wF^aRN|Nu2q2t8jYP;97H}!_- z5J5W-ERn18@=J(8W}+Ml;-wIgosjesdh_aZmz)$bJl6O?jj59iBq_2GGeoMPQsw@= zjMPJ-#iQkh9V0aCCWoFsog|lxOY?zhlJwb#-izddN{;j;{nG~we|2L*HCP^o`D06} zz#ubG4#n+xxL5iL^lrwL7c2*Z6+p&Ze)6S_k|ab8VR{)d4VG8&&vIvn)uCW{IAS-& zSSm5H5HrMXTkR^vTjPnLTbk|KX2aour4RpZi9mv;S|9Fj>dNJ!knR(7tgr8icr=eEsWXLZ@V%e2kh4yz-<`fyBkK| literal 0 HcmV?d00001 diff --git a/week4/homework/jack b/week4/homework/jack new file mode 100644 index 0000000..3b18e51 --- /dev/null +++ b/week4/homework/jack @@ -0,0 +1 @@ +hello world diff --git a/week4/homework/questions.txt b/week4/homework/questions.txt index 187b3d3..d687eac 100644 --- a/week4/homework/questions.txt +++ b/week4/homework/questions.txt @@ -3,12 +3,33 @@ Chapter 10 Basic Input and Output The Rake Gem: http://rake.rubyforge.org/ 1. How does Ruby read files? +Ruby reads files by opening the file with File.open and reading the +file with File.gets. You do not have to implicitly close the file - +that is done automatically at the end of the block. 2. How would you output "Hello World!" to a file called my_output.txt? +>> File.open("my_output.txt", "w") do |file| +?> file.puts "hello world" +>> end +=> nil +>> quit +m08642391% cat my_output.txt +hello world 3. What is the Directory class and what is it used for? +I'm not sure about this one. The only thing i found was a Dir class which +does things like list, change, create, delete directories. I used the following +code to output my current directory: + +> puts Dir.pwd +/Users/xok6/class/RubyWinter2014/week4/homework +=> nil 4. What is an IO object? +IO object is a class which handles input and output. It's a bidirectional +channel between a Ruby program an external resource. 5. What is rake and what is it used for? What is a rake task? - +rake is a gem for building ruby programs. Tasks are set up in a Rakefile. +These tasks are the build rules which tells your build what to do and which +files are involved with your build. diff --git a/week4/homework/worker.rb b/week4/homework/worker.rb new file mode 100644 index 0000000..9612ca5 --- /dev/null +++ b/week4/homework/worker.rb @@ -0,0 +1,7 @@ +class Worker + + def self.work n = 1 + n.times.inject(nil){yield} + end + +end From 356df709238f6627749ffc54f46c830907ad583d Mon Sep 17 00:00:00 2001 From: Jack Howland Date: Sun, 2 Mar 2014 19:23:16 -0800 Subject: [PATCH 7/7] completed week7 homework --- .gitignore | 3 + midterm/instructions_and_questions.txt | 39 --------- midterm/mid_term_spec.rb | 74 ------------------ midterm/wish_list_spec.rb | 18 ----- week3/exercises/.book.rb.swp | Bin 12288 -> 0 bytes week3/exercises/.book_spec.rb.swp | Bin 12288 -> 0 bytes week3/exercises/.monster.rb.swp | Bin 12288 -> 0 bytes week3/exercises/.monsters.rb.swp | Bin 12288 -> 0 bytes week3/exercises/.odd_number.rb.swp | Bin 12288 -> 0 bytes week3/homework/.calculator.rb.swp | Bin 12288 -> 12288 bytes week3/homework/.calculator_spec.rb.swp | Bin 12288 -> 0 bytes week4/class_materials/.code_timer.rb.swp | Bin 12288 -> 0 bytes week4/class_materials/.code_timer_spec.rb.swp | Bin 12288 -> 0 bytes week5/Rakefile.rb | 5 ++ week5/exercises/Rakefile.rb | 20 +++++ week5/test | 25 ++++++ week7/exercises/features/celsius.feature | 16 ++++ .../{converter.feature => fahrenheit.feature} | 7 +- .../features/step_definitions/converter.rb | 19 +++++ .../step_definitions/converter_steps.rb | 15 ++++ week7/features/cool_game.feature | 13 +++ week7/features/step_definitions/cool_game.rb | 25 ++++++ .../step_definitions/cool_game_steps.rb | 19 +++++ week7/homework/features.orig/pirate.feature | 11 +++ .../step_definitions/pirate_steps.rb | 19 +++++ .../step_definitions/tic-tac-toe-steps.rb | 0 .../tic-tac-toe.feature | 0 .../features/step_definitions/pirate.rb | 18 +++++ .../features/step_definitions/pirate_steps.rb | 2 + week7/homework/questions.txt | 51 +++++++++++- 30 files changed, 262 insertions(+), 137 deletions(-) delete mode 100644 midterm/instructions_and_questions.txt delete mode 100644 midterm/mid_term_spec.rb delete mode 100644 midterm/wish_list_spec.rb delete mode 100644 week3/exercises/.book.rb.swp delete mode 100644 week3/exercises/.book_spec.rb.swp delete mode 100644 week3/exercises/.monster.rb.swp delete mode 100644 week3/exercises/.monsters.rb.swp delete mode 100644 week3/exercises/.odd_number.rb.swp delete mode 100644 week3/homework/.calculator_spec.rb.swp delete mode 100644 week4/class_materials/.code_timer.rb.swp delete mode 100644 week4/class_materials/.code_timer_spec.rb.swp create mode 100644 week5/Rakefile.rb create mode 100644 week5/exercises/Rakefile.rb create mode 100644 week5/test create mode 100644 week7/exercises/features/celsius.feature rename week7/exercises/features/{converter.feature => fahrenheit.feature} (75%) create mode 100644 week7/exercises/features/step_definitions/converter.rb create mode 100644 week7/exercises/features/step_definitions/converter_steps.rb create mode 100644 week7/features/cool_game.feature create mode 100644 week7/features/step_definitions/cool_game.rb create mode 100644 week7/features/step_definitions/cool_game_steps.rb create mode 100644 week7/homework/features.orig/pirate.feature create mode 100644 week7/homework/features.orig/step_definitions/pirate_steps.rb rename week7/homework/{features => features.orig}/step_definitions/tic-tac-toe-steps.rb (100%) rename week7/homework/{features => features.orig}/tic-tac-toe.feature (100%) create mode 100644 week7/homework/features/step_definitions/pirate.rb diff --git a/.gitignore b/.gitignore index e43b0f9..07fbbce 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ .DS_Store +.*.swp +.*.un~ + diff --git a/midterm/instructions_and_questions.txt b/midterm/instructions_and_questions.txt deleted file mode 100644 index e38c84d..0000000 --- a/midterm/instructions_and_questions.txt +++ /dev/null @@ -1,39 +0,0 @@ -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: git@reneedv.com:RubyWinter2014/YOURREPOSITORYNAME.git - - Push your changes to the remote - - After 6pm Thursday February 20th 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. - - diff --git a/midterm/mid_term_spec.rb b/midterm/mid_term_spec.rb deleted file mode 100644 index 0556a97..0000000 --- a/midterm/mid_term_spec.rb +++ /dev/null @@ -1,74 +0,0 @@ -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 diff --git a/midterm/wish_list_spec.rb b/midterm/wish_list_spec.rb deleted file mode 100644 index 9ba4bce..0000000 --- a/midterm/wish_list_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require "#{File.dirname(__FILE__)}/wish_list" - -describe WishList do - before :each do - @wish_list = WishList.new - @wish_list.wishes = ["Lamborghini", "Corn Starch and Water Moat", "Vegan Bacon Ice Cream", "Rubber Chicken", "Free Tickets to Spamalot"] - end - - it "should mixin Enumerable" do - @wish_list.is_a?(Enumerable).should be_true - end - - context "#each" do - it "should give me a numberd list" do - @wish_list.map{|w| w}.should eq ["1. Lamborghini", "2. Corn Starch and Water Moat", "3. Vegan Bacon Ice Cream", "4. Rubber Chicken", "5. Free Tickets to Spamalot"] - end - end -end \ No newline at end of file diff --git a/week3/exercises/.book.rb.swp b/week3/exercises/.book.rb.swp deleted file mode 100644 index e8747d52902a259641e1847e8904dbcac2c15c14..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2%Wl&^6o#klxv$tA+_IvIb5jeIB8BddD2s~A0*PpBPZ}$O9odeWPyvs?Wx+EP zo}}#I4a%ZBV8xPuY*&b&3UyiWkMe2avCn0`o#hFdkM3^CdZVi_E-B@IJlftL-caF@ zQnPft=9d38wwkxry6w*GR>P*DwkJOR(k1jmtMlC7o(A*BaZ;G9-E4LJU1P=_-^@%F z#<|J;AWg@OEI2V0Z_oe@oZ7&7)oHhyE^OJmE?2KSJaq;J&;Sk401eOp4bT7$&;Sjb zT?55rNxee*=jtt7tLLSKxxVB?12jMbG(ZD1Km#;D12jMbG(ZD1a0U(N2%r5gDD?)o z@Bhc||6eaEbqKzI&)^d{03X0Ucn98s8Hm7B@C2-b6>u5+M9v@JJNO0;!2x&=T)o$T zg9d1T255i=Xn+Q2fCgxQ258{_G$3M9Aq0ar;rJ%54U&lmfr-vE&{wb zI@*2HxDM(Yz)1Jj-R=KfJJpT#X1%dl^AjDaRrRjm-bGwSmufWF(3xS zfEW-1Vn7Ut0WomO4P=8QIOHDAlzm(+$EAg_{3?SO5CdXB42S_SAO^&M7!U(uKn#ch zF>neEs0d(l8Q?wR{{Nr;{{L|S;5+k$`OLg!o-@ywr_7MK&0Jwtm~+fo=I08)N9Hy2 zih0QxW{3E5CdXB42S_SAO^&M7!U*hHb7|v zSbX4gK)mD5Qu|q)CFI+#&XWk~0KErBcZ}-y6oum#_hwM!1&1M~DLsXLJp^M2hb~w-lrFlOfgL)r})kUP+ zTiMsNp>mss>_Decn+tf8`3rq?)nh_6Q)_1XvjJQl=VI3$z;Qg8%>k diff --git a/week3/exercises/.monster.rb.swp b/week3/exercises/.monster.rb.swp deleted file mode 100644 index 0d5d72004f4a6ee7274697eec2f93850fa813aad..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI&ziSjh6bJAZyDj{Y2-f2nNW|s#ei1bgut<~QEJD;mB+TtT&moi9IJ0|+7Rg_c zB7cvSX>0^-g9!N(EPZp?1QCLyun2qy-p%gJ+c&eHZnzzFUak$*(Pf-##QWlo$espW!~y% zyvIH_fkU=kx*&6HKf1IUCLjQTs|nnsey`h!&pc?|S9j-LT+4IrJaL zgTMU$e}4Y|d7J2)#3zX(iCu|Wq9-vgF)Q&)l7C2imG~kNYkZbKg8&2|009U<00Izz z00bZa0SNp*0d_?~iTqNMJhMCwYDL8^-WJ-8*~gLQDh^I;?bz#)v8FN{CnvRy6Rymw z+Bm6Y~7NHlEc&JBwQ^HmjH^2Re;=vd2 z;K2tF#0T);NfB>?-aJ|#px6fx{7#xeW0Kl}m*Q{W!(?}6cE7*R?q$gY`Q=*`?^3qR z&`vUT0nX^XLSy*lSk|E*Q>m*>jG(v?D1>5!|5(;vGF=0e4-%~jK&SCerf zOfg?5=ek0ymU3cUm{3|_bCHfM#%$IE6E8;tWPl7D$iOr!6$^Q{_T1FfdX zWPl8i0Wv@a$N(8217v^<9Buc{{YAOmE843GgbKnBPF z86X2>fDDjH` z*We|120Gw2*qmnU2lx)Yf_LB*cnThXyPygdK>?fwzmVw*_&CV--esgl2FL&zAOmE8 z43GgbKnBRbe{A3pJ9<@#mh~2{d3pR^OI0ik52TWb6#dh6fALPy&v?EJh3i7C8vaTK zlN&s4VVkjATla0+Y+?g*B6Yky8tX7gP0W=WZ*paYTNCq0xD)<$r2{|1W_LC#d-L<& zL$*6lc~TxL)tWG4G6XUa)@8Jz;YrxWK|knFl*FXNNovA~u2#*x(-bGA>1y3@_iTue zcVx0{zi#b@Sc*bcCuF~?OrF=R_?2kWgc~;!Bg5x z>%>Bu{iS0H;mP3cLl1n6Y*%$^T+yT2N8f--8b!T-nRWD~9FuWB$?oYWkYhCN(z@W) GSJ-c&=su7D diff --git a/week3/exercises/.odd_number.rb.swp b/week3/exercises/.odd_number.rb.swp deleted file mode 100644 index 0ea535d751c162c7dec42109a3bcf11119956312..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI&Jxjwt7zgmHvr^G7aO$E6c_->1xH?opsE#Gcop3ZJk{4SY6ddZLU&dW0zk}aG zH&>se7YCt27a{OJ`1j$i&mFzr7MjpHJ?!xv!(%j-tB>jEela#qhki5vtM;s2-*enO z+lbRBh-bFmRtK6<9OSuqQij)ODk)^7s@l` ziSkH!piC(B-WJ{+KN$iLfB*y_009U<00Izz00bcLKLWBE2|a>yt_$ah91X65_*jUe z=?n0*uz5f$rR3Y(-lAS1&v{-(QL~TJ&>j1{?$k{xQH2U(btCmMtKYuoKZmn#=~z?U diff --git a/week3/homework/.calculator.rb.swp b/week3/homework/.calculator.rb.swp index 9225e78caff7e766b580fb89ef81ea5c2414b07e..daabfe08f89a86a9cedc0ad26462618dc5242a0f 100644 GIT binary patch delta 69 zcmZojXh@hK!I5dpz)+E&Z8mYEinyb837@47#siq delta 77 zcmZojXh@hK!4dMFfuSNl+ic=S6@Fg>3o{cVV@pH5oc!d(oQaB(8*^%zSxZaObS*Z& fW1b|#xP5b@f+pYO`+A%#sXzc^Xl%Z(r^pBZ??xJV diff --git a/week3/homework/.calculator_spec.rb.swp b/week3/homework/.calculator_spec.rb.swp deleted file mode 100644 index d2f4b08c88bf347f8c85c4302c3f0b5035a1597f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2&u`R56vro=8X$n^k4rC)L?{b2_S(Do0U}Z*no3kcNI|7YsH(i)Nn)+-acpmv z6#}IG1)yLU2Xm#E~m)A}&4lz@gvSb#~XG+4$P_S^3D>-I@2^d}hYl zDATCkyn2lm%(}pJN{GK6?XI-sS#f7ah&!q^uirlGx>jABuRFDiwizhT4GwI6Uk9|j zz)e$YrQPU$<42iHoT^>7I#RZ3*18I1MQpu>m%~2G{@_U;}J`4X^<=@Lw>H#S`KI267}H%oq86V&6S~ z$u~B@2G{@_U;}J`4X^<=zy{a=8(;%$;9qFKZ3^-310gC$Q9SEdh=n`1)!2DZT#@WC=z0++!@;7^Qm2mAq^f^Dz` zegJFWGN^+ZxBv{G-OK{M*Z><~18jf|umLvke=;B=d{HFIZ~b2g*W~BJvzq3r>s9RP zIWt{X?Vw3=gKG26;$pRmoNGW#&M_wV+-Pju zDHC_DL|A7utkWxDe6dc6p!R4`yF^gC7j*3S3vSEA>`NtT%G68zhNS74f%QDy46SEb ze95w8WOn?PAIqlinkred^egMjy-C6d@S_(%Va{XKsW?WhpfDyeS#!+H4`q6nVmiM> z4&Bq;Cu3S7UAXp}xPFSIpdv|8J8Z~=GSyoch=~_i6mF!jP?G%Pyx_bF1nU)3s3vR& znI8w;%5BGRz8#%`y3Ve%=1qKLb|Z3=#O>--{R-0l#Ey%Mz=y@nI;s$_;D4{gf&Nb7 zXOgffGF?%VJk`YBP_Uu*hzbJL@uRg%sDFm8M;@BueYc@D_d3NmP;F?t12e-dL^QfV z({@<7Z5uUX&R8%m4*e`)g67csA2unv^k-tIDs-dnzVY>PkIlMZ*mfbIy;wTo`#wwL zD&!nM78OB++FEh_DvN_SLzXFFYN9GTE=gQz@ycx+3M%9p5 gDpEf>QRpDjuvzb+n#hf|k5;qh$kBS7s-G2q1J3dktN;K2 diff --git a/week4/class_materials/.code_timer.rb.swp b/week4/class_materials/.code_timer.rb.swp deleted file mode 100644 index a08c747db3513d873a827c64a8c8c3d35d39b464..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI&Jx;?g6bJBEHU2uvlgKuynebm{uqs#sY*nran_AOHafKmY;|fB*y_0D=D@P@OjD znvXJ9A7{Sq8$bGbhzcm zEFX$3QC4A5nPg_^2l1u27^PArmnLUsMf-aJCllEdrBppr9q5PjB5S)u=JmbU6&NU??E?0K5cMP1M%0lc+6~GBGg(q^iJZ`Ok$~b?o$fr@&G+Rz3n^ zhlTP*U`Ap>06yzO=+yz6h1ulS3 zmxTBL-hxx`8oUB0AP4ur0BnFJxCmB21C%+=p+}C)2G{@_U;}J`4X^<=zy{a=8~CRU z$P8b9L}W({L{V-s?G%T(Nn?`7xWO0qqQrrnI)^Tbq6&y$AIpCN#$^I&6{L_Q9cl3O5gCLpy~wVQVkTr)?+5VqZyZ6dG^#%7(SLWy5*i zdO*T6N`ptWcv=}*=2^rkS0K-#vLu*ohNUCiiI>(wEkxZ}l_8czq>@nndehRKlE)@d MlGdHtwfc4O6XWdGQvd(} diff --git a/week5/Rakefile.rb b/week5/Rakefile.rb new file mode 100644 index 0000000..5c06720 --- /dev/null +++ b/week5/Rakefile.rb @@ -0,0 +1,5 @@ +task :default => [:say_hello] +desc "output to world" +task :say_hello do + puts "hello world" +end diff --git a/week5/exercises/Rakefile.rb b/week5/exercises/Rakefile.rb new file mode 100644 index 0000000..add77aa --- /dev/null +++ b/week5/exercises/Rakefile.rb @@ -0,0 +1,20 @@ +task :default => [:test3] + +task :test1 do + File.open("names") do |file| + while line = file.gets + puts line + end + end +end +task :test2 do + Dir.mkdir("class") unless Dir.exists? "class" +end +task :test3 do + Dir.mkdir("class") # unless Dir.exists? "class" + File.open("names") do |file| + while line = file.gets + Dir.mkdir line.chomp unless file.directory? line.chomp + end + end +end diff --git a/week5/test b/week5/test new file mode 100644 index 0000000..b6067b2 --- /dev/null +++ b/week5/test @@ -0,0 +1,25 @@ +asfdfsda +fads +fads +afsd +asfd +fascda +sfasd +asdf +dasf +fads +c +fdsa +fdsa +fdsa +fdsa +fds +fsa +fasd +fdsa +dfas +fdsa +fads +fds +fdas +fda diff --git a/week7/exercises/features/celsius.feature b/week7/exercises/features/celsius.feature new file mode 100644 index 0000000..9a53384 --- /dev/null +++ b/week7/exercises/features/celsius.feature @@ -0,0 +1,16 @@ +Feature: Converting metric + In order to pack for London + As a traveler + I want to be told the Celsius temperature in Fahrenheit + +Scenario: + Given I have entered 0 into the converter + And I set the type to "Celsius" + When I press convert + Then the result returned should be 32.0 + +Scenario: + Given I have entered 21 into the converter + And I set the type to "Celsius" + When I press convert + Then the result returned should be 69.8 diff --git a/week7/exercises/features/converter.feature b/week7/exercises/features/fahrenheit.feature similarity index 75% rename from week7/exercises/features/converter.feature rename to week7/exercises/features/fahrenheit.feature index 5e262a8..7e3c0ff 100644 --- a/week7/exercises/features/converter.feature +++ b/week7/exercises/features/fahrenheit.feature @@ -5,13 +5,12 @@ Feature: Converting metric Scenario: Given I have entered 32 into the converter - And I set the type to Fahrenheit + And I set the type to "Fahrenheit" When I press convert Then the result returned should be 0.0 Scenario: Given I have entered 75 into the converter - And I set the type to Fahrenheit + And I set the type to "Fahrenheit" When I press convert - Then the result returned should be 23.9 - + Then the result returned should be 23.9 diff --git a/week7/exercises/features/step_definitions/converter.rb b/week7/exercises/features/step_definitions/converter.rb new file mode 100644 index 0000000..ab60db0 --- /dev/null +++ b/week7/exercises/features/step_definitions/converter.rb @@ -0,0 +1,19 @@ +class Converter + attr_accessor :type + def initialize value + @value = value.to_f + end + + def convert + send "#{@type}_converter" + + end + private + def Fahrenheit_converter + ((@value - 32.0) * (5.0/9.0)).round(1) + end + + def Celsius_converter + (@value * (9.0/5.0) + 32.0).round(1) + end +end diff --git a/week7/exercises/features/step_definitions/converter_steps.rb b/week7/exercises/features/step_definitions/converter_steps.rb new file mode 100644 index 0000000..14ecd86 --- /dev/null +++ b/week7/exercises/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 "(.*?)"$/) do |type| + @converter.type = type +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 diff --git a/week7/features/cool_game.feature b/week7/features/cool_game.feature new file mode 100644 index 0000000..ce84882 --- /dev/null +++ b/week7/features/cool_game.feature @@ -0,0 +1,13 @@ +Feature: This is a really cool game. + +Scenario: Jack always wins the game. + Given "Jack" is logged in + When he clicks move + Then he wins the game + And he sees the text "You Won!" + + Scenario: Owen always loses the game. + Given "Owen" is logged in + When he clicks move + Then he loses the game + And he sees the text "You Lost!" diff --git a/week7/features/step_definitions/cool_game.rb b/week7/features/step_definitions/cool_game.rb new file mode 100644 index 0000000..d4a19ff --- /dev/null +++ b/week7/features/step_definitions/cool_game.rb @@ -0,0 +1,25 @@ +class CoolGame + def initialize name + @player = name + end + + def move + if @player == "Jack" + @won = true + else + @won = false + end + end + + def won? + @won + end + + def output + "You #{won? ? 'Won' : 'Lost'}!" + end + + def lose? + + end +end diff --git a/week7/features/step_definitions/cool_game_steps.rb b/week7/features/step_definitions/cool_game_steps.rb new file mode 100644 index 0000000..78652ca --- /dev/null +++ b/week7/features/step_definitions/cool_game_steps.rb @@ -0,0 +1,19 @@ +Given(/^"(.*?)" is logged in$/) do |name| + @game = CoolGame.new(name) +end + +When(/^he clicks move$/) do + @game.move +end + +Then(/^he wins the game$/) do + @game.won?.should be_true +end + +Then(/^he loses the game$/) do + @game.lose?.should be_false +end + +Then(/^he sees the text "(.*?)"$/) do |arg1| + @game.output.should eq arg1 +end diff --git a/week7/homework/features.orig/pirate.feature b/week7/homework/features.orig/pirate.feature new file mode 100644 index 0000000..7de1a0b --- /dev/null +++ b/week7/homework/features.orig/pirate.feature @@ -0,0 +1,11 @@ +# language: en-pirate + +Ahoy matey!: Pirate Speak + I would like help to talk like a pirate + +Heave to: The mighty speaking pirate + Gangway! I have a PirateTranslator + Blimey! I say 'Hello Friend' + Aye I hit translate + Let go and haul it prints out 'Ahoy Matey' + Avast! it also prints 'Shiber Me Timbers You Scurvey Dogs!!' diff --git a/week7/homework/features.orig/step_definitions/pirate_steps.rb b/week7/homework/features.orig/step_definitions/pirate_steps.rb new file mode 100644 index 0000000..faf1a7f --- /dev/null +++ b/week7/homework/features.orig/step_definitions/pirate_steps.rb @@ -0,0 +1,19 @@ +Gangway /^I have a (\w+)$/ do |arg| + @translator = Kernel.const_get(arg).new +end + +Blimey /^I (\w+) '(.+)'$/ do |method, arg| + @translator.send(method, arg) +end + +Letgoandhaul /^I hit (\w+)$/ do |arg| + @result = @translator.send(arg) +end + +Letgoandhaul /^it prints out '(.+)'$/ do |arg| + @result.split("\n ").first.should == arg +end + +Letgoandhaul /^it also prints '(.+)'$/ do |arg| + @result.split("\n ").last.should == arg +end diff --git a/week7/homework/features/step_definitions/tic-tac-toe-steps.rb b/week7/homework/features.orig/step_definitions/tic-tac-toe-steps.rb similarity index 100% rename from week7/homework/features/step_definitions/tic-tac-toe-steps.rb rename to week7/homework/features.orig/step_definitions/tic-tac-toe-steps.rb diff --git a/week7/homework/features/tic-tac-toe.feature b/week7/homework/features.orig/tic-tac-toe.feature similarity index 100% rename from week7/homework/features/tic-tac-toe.feature rename to week7/homework/features.orig/tic-tac-toe.feature diff --git a/week7/homework/features/step_definitions/pirate.rb b/week7/homework/features/step_definitions/pirate.rb new file mode 100644 index 0000000..7384ae3 --- /dev/null +++ b/week7/homework/features/step_definitions/pirate.rb @@ -0,0 +1,18 @@ +#class String +# def to_pirate_symbol +# self.downcase.gsub(' ', '_').intern +# end +#end + +class PirateTranslator + puts "Hello Friend" +end + +def say something + @said = something +end + +def translate + jack = [ 'Ahoy Matey', 'Shiber Me Timbers You Scurvey Dogs!!' ] + p "#{jack[0]}" + "\n #{jack[1]}" +end diff --git a/week7/homework/features/step_definitions/pirate_steps.rb b/week7/homework/features/step_definitions/pirate_steps.rb index faf1a7f..0aa06e8 100644 --- a/week7/homework/features/step_definitions/pirate_steps.rb +++ b/week7/homework/features/step_definitions/pirate_steps.rb @@ -8,6 +8,7 @@ Letgoandhaul /^I hit (\w+)$/ do |arg| @result = @translator.send(arg) + puts "#{arg}" end Letgoandhaul /^it prints out '(.+)'$/ do |arg| @@ -15,5 +16,6 @@ end Letgoandhaul /^it also prints '(.+)'$/ do |arg| + puts "#{arg}" @result.split("\n ").last.should == arg end diff --git a/week7/homework/questions.txt b/week7/homework/questions.txt index d55387d..d068fb7 100644 --- a/week7/homework/questions.txt +++ b/week7/homework/questions.txt @@ -2,8 +2,55 @@ Please Read Chapters 23 and 24 DuckTyping and MetaProgramming Questions: -1. What is method_missing and how can it be used? +1. What is method_missing and how can it be used? +Method missing is a method that you can define as a default method to use if an +object uses a method that is undefined. + +eg: +M08642391% irb +>> class Jack +>> def method_missing(name, *args) +>> puts "Jack is awesome at #{name}: #{args[0]}" +>> end +>> end +=> nil +>> jack = Jack.new +=> # +>> jack.ruby("RUBY!!!") +Jack is awesome at ruby: RUBY!!! +=> nil +-------------------------------------------------------------------------------- 2. What is and Eigenclass and what is it used for? Where Do Singleton methods live? +Eigenclass is another name for the singleton class and are used for defining methods +that are specific to a particular object. + +M08642391% irb +>> class Jack +>> end +=> nil +>> jack=Jack.new +=> # +>> def jack.atbat +>> puts "Jack hit a home run!!" +>> end +=> nil +>> jack.atbat +Jack hit a home run!! + +-------------------------------------------------------------------------------- 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? +Ducktyping is writing code that works with objects regardless of what type the +object is. Opting to use ducktyping can reduce the amount of code and in some +case can improve performance to your application. +-------------------------------------------------------------------------------- +4. What is the difference between a class method and an instance method? What is +the difference between instance_eval and class_eval? +the difference between a class method and an instance method is that instant +method works on normal objacts and class methods work on class objects. +The instance_eval can be used to perform immediate evalualtion on an object. +The class_eval works the same way, but the method works as though it were in a +class. +-------------------------------------------------------------------------------- 5. What is the difference between a singleton class and a singleton method? +A singleton method is a method defined for a single oject and a singleton class +is a method defined for an entire class.