From b58dfa242545eee025bd401421549debe378852b Mon Sep 17 00:00:00 2001 From: Sunny Ripert Date: Fri, 25 May 2018 08:20:06 -0400 Subject: [PATCH] Typographic spacing fixes --- source/try_ruby_en.json | 28 ++++++++++++++-------------- translations/en/try_ruby_170.md | 8 ++++---- translations/en/try_ruby_180.md | 4 ++-- translations/en/try_ruby_230.md | 6 +++--- translations/en/try_ruby_320.md | 18 +++++++++--------- translations/en/try_ruby_330.md | 6 +++--- translations/en/try_ruby_360.md | 6 +++--- translations/en/try_ruby_370.md | 8 ++++---- translations/en/try_ruby_40.md | 6 +++--- translations/en/try_ruby_410.md | 2 +- translations/en/try_ruby_440.md | 8 ++++---- translations/en/try_ruby_450.md | 6 +++--- translations/en/try_ruby_460.md | 12 ++++++------ translations/en/try_ruby_540.md | 6 +++--- translations/en/try_ruby_550.md | 20 ++++++++++---------- 15 files changed, 72 insertions(+), 72 deletions(-) diff --git a/source/try_ruby_en.json b/source/try_ruby_en.json index 503931a0..7e68dafc 100644 --- a/source/try_ruby_en.json +++ b/source/try_ruby_en.json @@ -2,7 +2,7 @@ "1": {"lang": "EN", "title": "Got 30 minutes? Give Ruby a shot right now!", "chapter": "Y", "answer": "", "ok": "", "error": "", "text": "%3Cp%3ERuby%20is%20a%20programming%20language%20from%20Japan%20which%20is%20revolutionizing%0Asoftware%20development.%3C/p%3E%0A%0A%3Cp%3EThe%20beauty%20of%20Ruby%20is%20found%20in%20its%20balance%20between%20simplicity%20and%20power.%3C/p%3E%0A%0A%3Cp%3EYou%20can%20type%20some%20Ruby%20code%20in%20the%20editor%20and%20use%20these%20buttons%20to%20navigate:%3C/p%3E%0A%0A%3Cul%3E%0A%3Cli%3E%3Cstrong%3ERun%3C/strong%3E%20→%20Executes%20the%20code%20in%20the%20editor%3C/li%3E%0A%3Cli%3E%3Cstrong%3ECopy%3C/strong%3E%20→%20Copies%20the%20example%20code%20to%20the%20editor%3C/li%3E%0A%3Cli%3E%3Cstrong%3ENext%3C/strong%3E%20→%20Allows%20you%20to%20go%20to%20the%20next%20lesson%3C/li%3E%0A%3Cli%3E%3Cstrong%3EBack%3C/strong%3E%20→%20Allows%20you%20to%20return%20to%20the%20previous%20lesson%3C/li%3E%0A%3Cli%3E%3Cstrong%3EClear%3C/strong%3E%20→%20Clears%20the%20editor%3C/li%3E%0A%3C/ul%3E%0A%0A%3Cp%3EUse%20the%20‘world’%20button%20%3Cspan%20aria-hidden=%22true%22%20class=%22glyphicon%20glyphicon-globe%22%3E%3C/span%3E%0Aabove%20to%20change%20TryRuby’s%20language.%3C/p%3E%0A%0A%3Ch3%3EClick%20on%20%3Cstrong%3ENext%3C/strong%3E%20to%20start%20learning.%3C/h3%3E%0A", "load_code": ""}, "2": {"lang": "EN", "title": "Using the editor", "chapter": "N", "answer": "%5E%5Cd%7B1,%7D$", "ok": "Good!%20You%20did%20a%20bit%20of%20math.%20See%20how%20the%20answer%20popped%20out?", "error": "Type%202%20+%206%20in%20the%20editor", "text": "%3Cp%3EThe%20editor%20window%20at%20the%20bottom%20is%20where%20you%20type%20your%20Ruby%20code,%20hit%20the%20%3Cstrong%3ERun%3C/strong%3E%20button%20and%0Awatch%20it%20run!%3C/p%3E%0A%0A%3Cp%3EFor%20example,%20try%20typing%20some%20math.%20Like:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3E2%20+%206%0A%3C/code%3E%3C/pre%3E%0A%0A%3Cp%3EThe%20output%20of%20your%20program%20should%20show%20itself%20at%20the%20output%20window%20at%20the%20top.%0AThere%20should%20also%20be%20a%20line%20that%20tells%20you%20how%20well%20you%20did.%3C/p%3E%0A%0A%3Cblockquote%3E%0A%3Cp%3EAlternatively%20you%20can%20hit%20the%20%3Cstrong%3ECopy%3C/strong%3E%20button%20to%20copy%20the%20example%20code%20to%20the%20editor.%3C/p%3E%0A%3C/blockquote%3E%0A", "load_code": ""}, "3": {"lang": "EN", "title": "Numbers and Math", "chapter": "N", "answer": "%5E[0-9%5C.,-]%7B1,%7D$", "ok": "Good", "error": "", "text": "%3Cp%3ERuby%20recognizes%20numbers%20and%20mathematic%20symbols.%20You%20could%20try%20some%20other%20math%20like:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3E4%20*%2010%0A5%20-%2012%0A30%20/%204%0A%3C/code%3E%3C/pre%3E%0A", "load_code": ""}, - "4": {"lang": "EN", "title": "Putting it differently", "chapter": "N", "answer": "%5E[0-9%5C.,-]%7B1,%7D$", "ok": "Well%20put", "error": "", "text": "%3Cp%3EDid%20you%20notice%20that%20if%20you%20typed%20more%20than%20one%20formula%20you%20only%20saw%20the%20answer%20for%20the%20last%20one.%0AWhat%20is%20going%20on%20?%3C/p%3E%0A%0A%3Cblockquote%3E%0A%3Cp%3ETo%20make%20this%20website%20easier%20to%20use%20I%20have%20told%20Ruby%20to%20copy%20the%20result%20of%20your%20program%20to%20the%0Aoutput%20screen%20at%20the%20top.%20So%20when%20you%20type%20a%20formula%20you%20get%20to%20see%20the%20results.%0A%3Cstrong%3EBut%20only%20the%20last%20result.%3C/strong%3E%20And%20only%20if%20the%20output%20is%20still%20empty.%3C/p%3E%0A%3C/blockquote%3E%0A%0A%3Cp%3ESo%20when%20you%20entered%202%20or%20more%20formula’s,%20Ruby%20only%20showed%20the%20result%20of%20the%20last%20formula.%3C/p%3E%0A%0A%3Cp%3EOf%20course%20you%20have%20the%20power%20to%20control%20the%20screen%20!%20Just%20type%20%3Cstrong%3Eputs%3C/strong%3E%20before%20each%20formula%0A(with%20a%20space%20in%20between).%20Puts%20means:%20%3Cem%3E‘put%20something%20on%20the%20screen’%3C/em%3E.%3C/p%3E%0A%0A%3Cp%3ETry%20this:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Eputs%204%20*%2010%0Aputs%205%20-%2012%0Aputs%2030%20/%204%0A%3C/code%3E%3C/pre%3E%0A%0A%3Cp%3ENow%20remove%20the%20puts%20from%20the%20last%20formula%20and%20see%20what%20happens.%3C/p%3E%0A", "load_code": ""}, + "4": {"lang": "EN", "title": "Putting it differently", "chapter": "N", "answer": "%5E[0-9%5C.,-]%7B1,%7D$", "ok": "Well%20put", "error": "", "text": "%3Cp%3EDid%20you%20notice%20that%20if%20you%20typed%20more%20than%20one%20formula%20you%20only%20saw%20the%20answer%20for%20the%20last%20one.%0AWhat%20is%20going%20on?%3C/p%3E%0A%0A%3Cblockquote%3E%0A%3Cp%3ETo%20make%20this%20website%20easier%20to%20use%20I%20have%20told%20Ruby%20to%20copy%20the%20result%20of%20your%20program%20to%20the%0Aoutput%20screen%20at%20the%20top.%20So%20when%20you%20type%20a%20formula%20you%20get%20to%20see%20the%20results.%0A%3Cstrong%3EBut%20only%20the%20last%20result.%3C/strong%3E%20And%20only%20if%20the%20output%20is%20still%20empty.%3C/p%3E%0A%3C/blockquote%3E%0A%0A%3Cp%3ESo%20when%20you%20entered%202%20or%20more%20formula’s,%20Ruby%20only%20showed%20the%20result%20of%20the%20last%20formula.%3C/p%3E%0A%0A%3Cp%3EOf%20course%20you%20have%20the%20power%20to%20control%20the%20screen!%20Just%20type%20%3Cstrong%3Eputs%3C/strong%3E%20before%20each%20formula%0A(with%20a%20space%20in%20between).%20Puts%20means:%20%3Cem%3E‘put%20something%20on%20the%20screen’%3C/em%3E.%3C/p%3E%0A%0A%3Cp%3ETry%20this:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Eputs%204%20*%2010%0Aputs%205%20-%2012%0Aputs%2030%20/%204%0A%3C/code%3E%3C/pre%3E%0A%0A%3Cp%3ENow%20remove%20the%20puts%20from%20the%20last%20formula%20and%20see%20what%20happens.%3C/p%3E%0A", "load_code": ""}, "5": {"lang": "EN", "title": "Say Your Name", "chapter": "N", "answer": "[a-zA-Z]%7B1,1%7D", "ok": "Perfect,%20you've%20formed%20a%20string%20from%20the%20letters%20of%20your%20name", "error": "", "text": "%3Cp%3ESure,%20computers%20are%20handy%20and%20fast%20for%20math.%20Let’s%20move%20on.%20Want%20to%20see%20your%20name%20reversed?%3C/p%3E%0A%0A%3Cp%3EFirst%20type%20your%20first%20name%20in%20quotes%20like%20this:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3E"Jimmy"%0A%3C/code%3E%3C/pre%3E%0A", "load_code": ""}, "6": {"lang": "EN", "title": "Say Your Name Backwards", "chapter": "N", "answer": "%5Cw+", "ok": "dooG", "error": "", "text": "%3Cp%3EA%20string%20is%20a%20set%20of%20characters%20the%20computer%20can%20process.%20Imagine%20the%20letters%20are%20on%20a%20string%20of%0Alaundry%20line%20and%20the%20quotes%20are%20clothespins%20holding%20the%20ends.%20The%20quotes%20mark%20the%20beginning%20and%20end.%3C/p%3E%0A%0A%3Cp%3ETo%20reverse%20your%20name,%20type:%20%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3E"Jimmy".reverse%0A%3C/code%3E%3C/pre%3E%0A%0A%3Cp%3E(Don’t%20forget%20the%20dot!)%3C/p%3E%0A", "load_code": ""}, "7": {"lang": "EN", "title": "Counting the Letters", "chapter": "N", "answer": "%5E%5Cd+$", "ok": "Yep.%20Length%20is%20also%20a%20'method'", "error": "", "text": "%3Cp%3EYou%20have%20used%20the%20reverse%20%3Cstrong%3Emethod%3C/strong%3E%20on%20your%20name!%20By%20enclosing%20your%20name%20in%20quotes,%20you%20made%20a%20string.%20Then%20you%20called%20the%20reverse%20method,%20which%20works%20on%20strings%20to%20flip%20all%20the%20letters%20backwards.%3C/p%3E%0A%0A%3Cp%3ENow,%20let%20us%20see%20how%20many%20letters%20are%20in%20your%20name:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3E"Jimmy".length%0A%3C/code%3E%3C/pre%3E%0A", "load_code": ""}, @@ -15,13 +15,13 @@ "14": {"lang": "EN", "title": "Tucking a List Away", "chapter": "N", "answer": "%5E%5C[(%5Cd+)(,%5Cs*%5Cd+)%7B2,%7D%5C]$", "ok": "Saved!", "error": "", "text": "%3Cp%3EGood,%20good.%20But%20it’s%20annoying%20to%20have%20to%20retype%20that%20list%20every%20time%20you%20need%20it,%20isn’t%20it?%3C/p%3E%0A%0A%3Cp%3ELet’s%20save%20our%20numbers%20inside%20a%20ticket%20like%20so:%20%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Eticket%20=%20[12,%2047,%2035]%0A%3C/code%3E%3C/pre%3E%0A", "load_code": ""}, "15": {"lang": "EN", "title": "Now Type Ticket", "chapter": "N", "answer": "%5C[(%5Cd+(,%20)?)%7B2,%7D%5C]", "ok": "Restored!", "error": "", "text": "%3Cp%3ENow,%20type:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Eticket%0A%3C/code%3E%3C/pre%3E%0A", "load_code": "ticket%20=%20[12,%2047,%2035]"}, "16": {"lang": "EN", "title": "Saved, Tucked Away", "chapter": "N", "answer": "%5C[12,%2035,%2047%5C]", "ok": "You've%20sorted%20the%20list", "error": "", "text": "%3Cp%3EYou’ve%20hung%20on%20to%20your%20lotto%20numbers,%20tucking%20them%20away%20inside%20a%20%3Cstrong%3Evariable%3C/strong%3E%20called%20ticket.%0ABut%20any%20other%20name,%20like%20%3Cem%3Ejimmyslist%3C/em%3E,%20would%20have%20been%20fine%20to.%3C/p%3E%0A%0A%3Cp%3EProgramming,%20you%20will%20discover,%20is%20mostly%20about%20working%20with%20variables.%3C/p%3E%0A%0A%3Cp%3ELet’s%20put%20your%20lotto%20numbers%20in%20order,%20how%20about?%3C/p%3E%0A%0A%3Cp%3EUse:%20%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Eticket.sort!%0A%3C/code%3E%3C/pre%3E%0A%0A%3Cp%3EYou%20had%20a%20list.%20You%20sorted%20the%20list.%20The%20ticket%20variable%20is%20now%20changed.%3Cbr%3E%0ADid%20you%20notice%20that%20the%20%3Cem%3Esort!%3C/em%3E%20method%20has%20a%20big,%20bright%20exclamation%20at%20the%20end?%3Cbr%3E%0AA%20lot%20of%20times%20Ruby%20methods%20shout%20like%20that%20if%20they%20alter%20the%20variable%20for%20good.%0AIt’s%20nothin%20special,%20just%20a%20mark.%3C/p%3E%0A", "load_code": "ticket%20=%20[12,%2047,%2035]"}, - "17": {"lang": "EN", "title": "Elemental", "chapter": "N", "answer": "%5E(12%7C35%7C47)$", "ok": "Ok", "error": "Almost", "text": "%3Cp%3ESo%20we%20stored%20our%20lotto%20numbers%20inside%20variable%20ticket.%20How%20to%20get%20‘em%20out%20again%20?%3C/p%3E%0A%0A%3Cp%3EWe%20already%20saw%20that%20we%20can%20get%20the%20highest%20number%20with%20%3Cstrong%3Emax%3C/strong%3E.%20Similarly%20you%20can%0Aget%20the%20%3Cstrong%3Efirst%3C/strong%3E%20or%20the%20%3Cstrong%3Elast%3C/strong%3E%20element%20of%20the%20list.%0ABut%20what%20if%20you%20want%20a%20specific%20element%20?%3C/p%3E%0A%0A%3Ch3%3E[%20]%3C/h3%3E%0A%0A%3Cp%3ERuby%20uses%20the%20square%20brackets%20[%20]%20to%20target%20an%20element.%0AThe%20square%20brackets%20are%20very%20common%20in%20Ruby.%0AThey%20are%20like%20sights%20used%20to%20line%20up%20a%20target.%20Exactly.%0AThese%20brackets%20mean,%20“I%20am%20looking%20for%20____”%20Ready,%20aim.%3C/p%3E%0A%0A%3Cp%3ELet’s%20get%20all%20of%20our%20lotto%20numbers:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Eputs%20ticket[0]%0Aputs%20ticket[1]%0Aputs%20ticket[2]%0A%3C/code%3E%3C/pre%3E%0A%0A%3Cp%3EWhy%20do%20we%20use%20[0],%20[1],%20[2]%20?%3C/p%3E%0A%0A%3Cp%3EAnd%20not%20[1],%20[2]%20and%20[3]%20?%20Is%20that%20some%20kind%20of%20Japanese%20Zen%20thing%20?%0ANo,%20we%20computer%20people%20just%20like%20to%20begin%20counting%20from%20zero.%20It’s%20not%20just%20a%20Ruby%20thing,%0Athis%20%3Cem%3Ezero%20based%20indexing%3C/em%3E%20is%20used%20in%20most%20programming%20languages.%3C/p%3E%0A%0A%3Cblockquote%3E%0A%3Cp%3EA%20little%20reminder:%20you%20can%20use%20the%20%3Cstrong%3ECopy%3C/strong%3E%20button%20to%20copy%20the%20example%20code%20to%20the%20editor.%3C/p%3E%0A%3C/blockquote%3E%0A", "load_code": "ticket%20=%20[12,%2047,%2035]"}, - "18": {"lang": "EN", "title": "Summary #2 is Upon Us", "chapter": "Y", "answer": "%5Cw+", "ok": "Does%20it%20rhyme%20?", "error": "", "text": "%3Cp%3ENow,%20look%20how%20your%20second%20minute%20went:%3C/p%3E%0A%0A%3Ch3%3EErrors%3C/h3%3E%0A%0A%3Cp%3EIf%20you%20try%20to%20reverse%20a%20number%20or%20do%20anything%20fishy,%20Ruby%20will%20tell%20you%20so.%3C/p%3E%0A%0A%3Ch3%3EArrays%3C/h3%3E%0A%0A%3Cp%3EArrays%20are%20lists%20for%20storing%20things%20in%20some%20order.%0AWe%20also%20know%20how%20to%20create%20array’s%20and%20get%20items%20from%20array’s.%3C/p%3E%0A%0A%3Ch3%3EVariables%3C/h3%3E%0A%0A%3Cp%3EVariables%20save%20a%20thing%20and%20give%20it%20a%20name.%20You%20used%20the%20equals%20sign%20to%20do%20this.%20Like:%0Aticket%20=%20[14,%2037,%2018].%3C/p%3E%0A%0A%3Ch3%3E2/8%3C/h3%3E%0A%0A%3Cp%3EIn%20all%20there%20are%20eight%20sections.%20You%20are%20two-eighths%20of%20the%20way%20there!%20This%20is%20simple%20stuff,%0Adon’t%20you%20think?%20Good%20stuff%20up%20ahead.%3C/p%3E%0A%0A%3Cp%3ELet’s%20change%20directions%20for%20a%20moment.%20I’ve%20stuffed%20a%20bit%20of%20poetry%20for%20you%20in%20a%20certain%20variable.%0ATake%20a%20look.%20Type:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Eputs%20poem%0A%3C/code%3E%3C/pre%3E%0A", "load_code": "poem%20=%20%22My%20toast%20has%20flown%20from%20my%20hand%5CnAnd%20my%20toast%20has%20gone%20to%20the%20moon.%5CnBut%20when%20I%20saw%20it%20on%20television,%5CnPlanting%20our%20flag%20on%20Halley's%20comet,%5CnMore%20still%20did%20I%20want%20to%20eat%20it.%5Cn%22"}, + "17": {"lang": "EN", "title": "Elemental", "chapter": "N", "answer": "%5E(12%7C35%7C47)$", "ok": "Ok", "error": "Almost", "text": "%3Cp%3ESo%20we%20stored%20our%20lotto%20numbers%20inside%20variable%20ticket.%20How%20to%20get%20‘em%20out%20again?%3C/p%3E%0A%0A%3Cp%3EWe%20already%20saw%20that%20we%20can%20get%20the%20highest%20number%20with%20%3Cstrong%3Emax%3C/strong%3E.%20Similarly%20you%20can%0Aget%20the%20%3Cstrong%3Efirst%3C/strong%3E%20or%20the%20%3Cstrong%3Elast%3C/strong%3E%20element%20of%20the%20list.%0ABut%20what%20if%20you%20want%20a%20specific%20element?%3C/p%3E%0A%0A%3Ch3%3E[%20]%3C/h3%3E%0A%0A%3Cp%3ERuby%20uses%20the%20square%20brackets%20[%20]%20to%20target%20an%20element.%0AThe%20square%20brackets%20are%20very%20common%20in%20Ruby.%0AThey%20are%20like%20sights%20used%20to%20line%20up%20a%20target.%20Exactly.%0AThese%20brackets%20mean,%20“I%20am%20looking%20for%20____”%20Ready,%20aim.%3C/p%3E%0A%0A%3Cp%3ELet’s%20get%20all%20of%20our%20lotto%20numbers:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Eputs%20ticket[0]%0Aputs%20ticket[1]%0Aputs%20ticket[2]%0A%3C/code%3E%3C/pre%3E%0A%0A%3Cp%3EWhy%20do%20we%20use%20[0],%20[1],%20[2]?%3C/p%3E%0A%0A%3Cp%3EAnd%20not%20[1],%20[2]%20and%20[3]?%20Is%20that%20some%20kind%20of%20Japanese%20Zen%20thing?%0ANo,%20we%20computer%20people%20just%20like%20to%20begin%20counting%20from%20zero.%20It’s%20not%20just%20a%20Ruby%20thing,%0Athis%20%3Cem%3Ezero%20based%20indexing%3C/em%3E%20is%20used%20in%20most%20programming%20languages.%3C/p%3E%0A%0A%3Cblockquote%3E%0A%3Cp%3EA%20little%20reminder:%20you%20can%20use%20the%20%3Cstrong%3ECopy%3C/strong%3E%20button%20to%20copy%20the%20example%20code%20to%20the%20editor.%3C/p%3E%0A%3C/blockquote%3E%0A", "load_code": "ticket%20=%20[12,%2047,%2035]"}, + "18": {"lang": "EN", "title": "Summary #2 is Upon Us", "chapter": "Y", "answer": "%5Cw+", "ok": "Does%20it%20rhyme?", "error": "", "text": "%3Cp%3ENow,%20look%20how%20your%20second%20minute%20went:%3C/p%3E%0A%0A%3Ch3%3EErrors%3C/h3%3E%0A%0A%3Cp%3EIf%20you%20try%20to%20reverse%20a%20number%20or%20do%20anything%20fishy,%20Ruby%20will%20tell%20you%20so.%3C/p%3E%0A%0A%3Ch3%3EArrays%3C/h3%3E%0A%0A%3Cp%3EArrays%20are%20lists%20for%20storing%20things%20in%20some%20order.%0AWe%20also%20know%20how%20to%20create%20array’s%20and%20get%20items%20from%20array’s.%3C/p%3E%0A%0A%3Ch3%3EVariables%3C/h3%3E%0A%0A%3Cp%3EVariables%20save%20a%20thing%20and%20give%20it%20a%20name.%20You%20used%20the%20equals%20sign%20to%20do%20this.%20Like:%0Aticket%20=%20[14,%2037,%2018].%3C/p%3E%0A%0A%3Ch3%3E2/8%3C/h3%3E%0A%0A%3Cp%3EIn%20all%20there%20are%20eight%20sections.%20You%20are%20two-eighths%20of%20the%20way%20there!%20This%20is%20simple%20stuff,%0Adon’t%20you%20think?%20Good%20stuff%20up%20ahead.%3C/p%3E%0A%0A%3Cp%3ELet’s%20change%20directions%20for%20a%20moment.%20I’ve%20stuffed%20a%20bit%20of%20poetry%20for%20you%20in%20a%20certain%20variable.%0ATake%20a%20look.%20Type:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Eputs%20poem%0A%3C/code%3E%3C/pre%3E%0A", "load_code": "poem%20=%20%22My%20toast%20has%20flown%20from%20my%20hand%5CnAnd%20my%20toast%20has%20gone%20to%20the%20moon.%5CnBut%20when%20I%20saw%20it%20on%20television,%5CnPlanting%20our%20flag%20on%20Halley's%20comet,%5CnMore%20still%20did%20I%20want%20to%20eat%20it.%5Cn%22"}, "19": {"lang": "EN", "title": "Sadly, You Hate Toast Poetry", "chapter": "N", "answer": "(toast)%7B0%7D", "ok": "Excellent", "error": "Still%20smells%20like%20toast%20to%20me", "text": "%3Cp%3ELook,%20it’s%20okay.%20You%20don’t%20have%20to%20like%20it.%20Hack%20it%20up,%20be%20my%20guest.%20Instead%20of%20toast,%20go%20for%20a%0Amelon%20or%20something.%20Try%20this%20to%20see%20the%20new%20poem:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Epoem.gsub("toast",%20"honeydew")%0A%3C/code%3E%3C/pre%3E%0A%0A%3Cp%3EThe%20%3Cstrong%3Egsub%3C/strong%3E%20method%20is%20short%20for%20global%20substitute.%20It%20replaces%20all%20occurences%20of%20“toast”%20with%0A“honeydew”.%3C/p%3E%0A", "load_code": "prev"}, "20": {"lang": "EN", "title": "Ready, Aim", "chapter": "N", "answer": "%5E%5Cn.ti%20tae%20ot%20(.+)", "ok": "Okay,%20sure.%20%20So%20the%20whole%20poem%20has%20been%20turned%20backwards.", "error": "", "text": "%3Cp%3EHere’s%20a%20question:%20what%20happens%20when%20we%20reverse%20this%20whole%20poem?%20%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Epoem.reverse%0A%3C/code%3E%3C/pre%3E%0A", "load_code": "prev"}, "21": {"lang": "EN", "title": "Too Much Reversal", "chapter": "N", "answer": "%5E%5C[%22More%20still%20did%20(.+)", "ok": "Yes,%20almost%20what%20we%20want", "error": "", "text": "%3Cp%3ESo%20the%20whole%20poem’s%20been%20turned%20backwards,%20letter-by-letter.%20I%20really%20wanted%20to%20just%20reverse%20the%20lines%20though.%0AMove%20the%20last%20line%20up%20to%20first%20and%20the%20first%20line%20down%20to%20last.%3C/p%3E%0A%0A%3Cp%3EBackwards,%20but%20not%20%3Cstrong%3Ethat%3C/strong%3E%20backwards.%3C/p%3E%0A%0A%3Cp%3EHere’s%20how:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Epoem.lines.reverse%0A%3C/code%3E%3C/pre%3E%0A", "load_code": "prev"}, "22": {"lang": "EN", "title": "Ringlets of Chained Methods", "chapter": "N", "answer": "%5EMore%20still%20did%20(.+)", "ok": "Good%20show,%20my%20friend!%20The%20join%20method%20took%20that%20array%20of%20lines%20and%20put%20them%20together%20into%20a%20string.", "error": "", "text": "%3Cp%3ESo%20what%20do%20you%20see?%20What%20happened%20there?%20You%20typed%20%3Cstrong%3Epoem.lines.reverse%3C/strong%3E%20and%20what%20happened?%3C/p%3E%0A%0A%3Cp%3ETwo%20things%20happened.%20You%20turned%20the%20poem%20into%20a%20list%20using%20lines.%0ALines%20decides%20the%20way%20the%20string%20is%20split%20up%20and%20converts%20it%20into%20an%20Array.%3C/p%3E%0A%0A%3Cp%3EThen,%20you%20reversed%20that%20list.%20You%20had%20each%20line.%20You%20reversed%20them.%20That’s%20it.%3C/p%3E%0A%0A%3Cp%3ELet’s%20tack%20one%20more%20method%20on%20the%20end%20there:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Eputs%20poem.lines.reverse.join%0A%3C/code%3E%3C/pre%3E%0A%0A%3Cp%3ECombining%20methods%20like%20this%20is%20called%20%3Cem%3Emethod%20chaining%3C/em%3E.%3C/p%3E%0A", "load_code": "prev"}, - "23": {"lang": "EN", "title": "Of All the Summaries, #3 is Here Now", "chapter": "Y", "answer": "%5C%7B%5C%7D", "ok": "You've%20made%20an%20empty%20hash%20!", "error": "", "text": "%3Ch3%3EExclamations%3C/h3%3E%0A%0A%3Cp%3EMethods%20may%20have%20exclamations%20(and%20also%20question%20marks)%20in%20their%20name.%0AThese%20are%20just%20there%20to%20better%20explain%20what%20their%20function%20is.%20No%20big%20deal.%3C/p%3E%0A%0A%3Ch3%3EString%20manipulation%3C/h3%3E%0A%0A%3Cp%3ESearch%20and%20change%20strings%3C/p%3E%0A%0A%3Ch3%3EChaining%3C/h3%3E%0A%0A%3Cp%3EChaining%20methods%20lets%20you%20get%20a%20lot%20more%20done.%20Break%20up%20a%20poem,%20reverse%20it,%20reassemble%20it:%0A%3Cstrong%3Epoem.lines.reverse.join%3C/strong%3E%3C/p%3E%0A%0A%3Cp%3EAt%20this%20point,%20you%20may%20want%20to%20tinker%20with%20the%20poem%20a%20bit%20more.%20A%20complete%20list%20of%20all%20the%20String%0Amethods%20is%20%3Ca%20href=%22http://ruby-doc.org/core/classes/String.html%22%20target=%22_blank%22%3Ehere%3C/a%3E.%3C/p%3E%0A%0A%3Cp%3EGo%20ahead%20and%20try%20a%20few,%20such%20as:%20poem.downcase%20or%20poem.swapcase%3C/p%3E%0A%0A%3Ch2%3EReady%20?%3C/h2%3E%0A%0A%3Cp%3EWhen%20you%20feel%20ready%20to%20move%20on,%20type:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Ebooks%20=%20%7B%7D%0A%3C/code%3E%3C/pre%3E%0A", "load_code": "prev"}, + "23": {"lang": "EN", "title": "Of All the Summaries, #3 is Here Now", "chapter": "Y", "answer": "%5C%7B%5C%7D", "ok": "You've%20made%20an%20empty%20hash!", "error": "", "text": "%3Ch3%3EExclamations%3C/h3%3E%0A%0A%3Cp%3EMethods%20may%20have%20exclamations%20(and%20also%20question%20marks)%20in%20their%20name.%0AThese%20are%20just%20there%20to%20better%20explain%20what%20their%20function%20is.%20No%20big%20deal.%3C/p%3E%0A%0A%3Ch3%3EString%20manipulation%3C/h3%3E%0A%0A%3Cp%3ESearch%20and%20change%20strings%3C/p%3E%0A%0A%3Ch3%3EChaining%3C/h3%3E%0A%0A%3Cp%3EChaining%20methods%20lets%20you%20get%20a%20lot%20more%20done.%20Break%20up%20a%20poem,%20reverse%20it,%20reassemble%20it:%0A%3Cstrong%3Epoem.lines.reverse.join%3C/strong%3E%3C/p%3E%0A%0A%3Cp%3EAt%20this%20point,%20you%20may%20want%20to%20tinker%20with%20the%20poem%20a%20bit%20more.%20A%20complete%20list%20of%20all%20the%20String%0Amethods%20is%20%3Ca%20href=%22http://ruby-doc.org/core/classes/String.html%22%20target=%22_blank%22%3Ehere%3C/a%3E.%3C/p%3E%0A%0A%3Cp%3EGo%20ahead%20and%20try%20a%20few,%20such%20as:%20poem.downcase%20or%20poem.swapcase%3C/p%3E%0A%0A%3Ch2%3EReady?%3C/h2%3E%0A%0A%3Cp%3EWhen%20you%20feel%20ready%20to%20move%20on,%20type:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Ebooks%20=%20%7B%7D%0A%3C/code%3E%3C/pre%3E%0A", "load_code": "prev"}, "24": {"lang": "EN", "title": "A Wee Blank Book", "chapter": "N", "answer": "%5E(splendid%7Cquite_good%7Cmediocre%7Cquite_not_good%7Cabyssmal)$", "ok": "Yes%20that's%20a%20new%20review", "error": "Use%20one%20of%20splendid,%20quite_good,%20mediocre,%20quite_not_good,%20abyssmal.%20Don't%20forget%20the%20colon", "text": "%3Cp%3EYou’ve%20made%20an%20empty%20%3Cstrong%3Ehash%3C/strong%3E.%20A%20hash%20is%20like%20an%20array,%20only%20every%20one%20of%20its%20elements%20has%20a%20name.%3C/p%3E%0A%0A%3Cp%3EWe’re%20going%20to%20stuff%20some%20miniature%20book%20reviews%20in%20our%20new%20hash.%20Here’s%20our%20rating%20system:%3C/p%3E%0A%0A%3Cul%3E%0A%3Cli%3E:splendid%20→%20a%20masterpiece%3C/li%3E%0A%3Cli%3E:quite_good%20→%20enjoyed,%20sure,%20yes%3C/li%3E%0A%3Cli%3E:mediocre%20→%20equal%20parts%20great%20and%20terrible%3C/li%3E%0A%3Cli%3E:quite_not_good%20→%20notably%20bad%3C/li%3E%0A%3Cli%3E:abyssmal%20→%20steaming%20wreck%3C/li%3E%0A%3C/ul%3E%0A%0A%3Cp%3ETo%20rate%20a%20book,%20put%20the%20title%20in%20square%20brackets%20and%20put%20the%20rating%20after%20the%20equals.%20For%20example:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Ebooks["Gravitys%20Rainbow"]%20=%20:splendid%0A%3C/code%3E%3C/pre%3E%0A%0A%3Cblockquote%3E%0A%3Cp%3EBy%20now%20I%20think%20it%20is%20only%20fair%20to%20tell%20you%20that%20all%20lessons%20in%20TryRuby%20are%20separate%20from%20each%20other.%0ASo%20if%20you%20go%20crazy%20typing%20book%20reviews%20here,%20you%20can%20only%20use%20‘em%20in%20this%20lesson.%3Cbr%3E%0AIf%20you%20want%20to%20use%20your%20reviews%20in%20the%20next%20lesson%20you%20should%20copy/paste%20them.%3Cbr%3E%0ADon’t%20worry%20about%20this%20too%20much,%20each%20lesson%20has%20plenty%20of%20predefined%20stuff%20for%20you%20to%20play%20around%20with.%3C/p%3E%0A%3C/blockquote%3E%0A", "load_code": "books%20=%20%7B%7D"}, "25": {"lang": "EN", "title": "More Bite-Size Reviews", "chapter": "N", "answer": "[3-9]", "ok": "See,%20the%20length%20method%20works%20on%20strings,%20array's%20and%20hashes.", "error": "", "text": "%3Cp%3EKeep%20going,%20fill%20it%20up%20with%20reviews.%20And,%20if%20you%20want%20to%20see%20the%20whole%20list,%20just%20type:%20%3Cstrong%3Eputs%20books%3C/strong%3E%3C/p%3E%0A%0A%3Cp%3EAgain,%20the%20ratings%20are:%20:splendid,%20:quite_good,%20:mediocre,%20:quite_not_good%20and%20:abyssmal.%3C/p%3E%0A%0A%3Cp%3EThese%20ratings%20are%20not%20strings.%20When%20you%20place%20a%20colon%20in%20front%20of%20a%20simple%20word,%20you%20get%20a%20%3Cstrong%3Esymbol%3C/strong%3E.%0ASymbols%20are%20cheaper%20than%20strings%20(in%20terms%20of%20computer%20memory.)%20If%20you%20use%20a%20word%20over%20and%20over%20in%20your%20program,%0Ause%20a%20symbol.%20Rather%20than%20having%20thousands%20of%20copies%20of%20that%20word%20in%20memory,%20the%20computer%20will%20store%20the%20symbol%20only%0A%3Cstrong%3Eonce%3C/strong%3E.%3C/p%3E%0A%0A%3Cp%3EMore%20importantly,%20a%20symbol%20tells%20you%20that%20is%20not%20just%20any%20old%20word%20but%20has%20a%20meaning%20within%20your%20program.%3C/p%3E%0A%0A%3Cp%3EEnter%202%20more%20bookreviews,%20use%20%3Cstrong%3Ebooks.length%3C/strong%3E%20to%20see%20how%20many%20reviews%20there%20are%20in%20the%20hash:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Ebooks["The%20deep%20end"]%20%20=%20:abyssmal%0Abooks["Living%20colors"]%20=%20:mediocre%0A%0Aputs%20books%0A%0Aputs%20books.length%0A%3C/code%3E%3C/pre%3E%0A", "load_code": "books%20=%20%7B%22Gravitys%20Rainbow%22%20=%3E%20:splendid%7D"}, "26": {"lang": "EN", "title": "Wait, Did I Like Gravity's Rainbow?", "chapter": "N", "answer": "%5E(splendid%7Cquite_good%7Cmediocre%7Cquite_not_good%7Cabyssmal)$", "ok": "I%20liked%20it%20a%20lot", "error": "", "text": "%3Cp%3EOne%20great%20thing%20about%20Ruby%20is%20that%20names%20are%20often%20reused,%20which%20means%20fewer%20names%20you%20need%20to%20remember.%3C/p%3E%0A%0A%3Cp%3ERemember%20how%20we%20retrieved%20items%20from%20an%20array%20using%20a%20number:%3Cbr%3E%0A%3Cstrong%3Eputs%20ticket[1]%3C/strong%3E.%3C/p%3E%0A%0A%3Cp%3EFor%20a%20hash%20this%20works%20the%20same%20way,%20except%20we%20don’t%20use%20a%20number%20to%20get%20an%20element%20but%20a%20name.%3C/p%3E%0A%0A%3Cp%3ESo,%20if%20you’d%20like%20to%20look%20up%20one%20of%20your%20old%20reviews,%20again%20put%20the%20title%20in%20the%20square.%20But%20leave%20off%20the%20equals.%0AJust%20like%20this:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Eputs%20books["Gravitys%20Rainbow"]%0A%3C/code%3E%3C/pre%3E%0A", "load_code": "books%20=%20%7B%22Gravitys%20Rainbow%22%20=%3E%20:splendid,%20%22The%20deep%20end%22%20=%3E%20:abyssmal,%20%22Living%20colors%22%20=%3E%20:mediocre%7D"}, @@ -30,21 +30,21 @@ "29": {"lang": "EN", "title": "A Tally", "chapter": "N", "answer": "%5Cw+", "ok": "Yodelay!", "error": "", "text": "%3Cp%3EOne%20of%20the%20amazing%20new%20things%20we’ve%20just%20used%20is%20a%20%3Cstrong%3Eblock%3C/strong%3E.%20We’re%20going%20to%20explore%20these%20more%0Ain%20this%20and%20the%20next%20lesson.%20But,%20basically,%20a%20block%20is%20a%20bit%20of%20Ruby%20code%20surrounded%20by%20curly%0Abraces.%3C/p%3E%0A%0A%3Cp%3ELet’s%20try%20another%20block:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3E5.times%20%7B%20print%20"Odelay!%20"%20%7D%0A%3C/code%3E%3C/pre%3E%0A%0A%3Cp%3EBlocks%20are%20always%20attached%20to%20methods.%20Like%20the%20%3Cstrong%3Etimes%3C/strong%3E%20method,%20which%20takes%20the%20block%20and%20runs%0Athe%20code%20over%20and%20over.%20(In%20our%20example:%20five%20times.)%3C/p%3E%0A", "load_code": ""}, "30": {"lang": "EN", "title": "Have you got the time?", "chapter": "N", "answer": "%5E[0-9]$", "ok": "You%20timed%20it%20just%20right!", "error": "Run%20the%20block%200%20to%209%20times", "text": "%3Cp%3EAs%20we%20saw%20in%20the%20first%20example%20with%20a%20block%20(when%20counting%20ratings)%20we%20can%20pass%20a%20value%20to%20the%20block.%20Which%0Avalues%20are%20%3Cstrong%3Epassed%3C/strong%3E%20is%20determined%20by%20the%20method%20that%20is%20running%20the%20block.%3C/p%3E%0A%0A%3Cp%3EThe%20values%20that%20are%20%3Cstrong%3Ereceived%3C/strong%3E%20by%20the%20block%20are%20placed%20in%20the%20variable%20name%20at%20the%20beginning%20of%20the%20block,%0Abetween%20two%20pipe%20symbols:%20%7C%3C/p%3E%0A%0A%3Cp%3ELet’s%20try%20that%20with%20this%20block:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3E5.times%20%7B%20%7Ctime%7C%0A%20%20puts%20time%0A%7D%0A%3C/code%3E%3C/pre%3E%0A%0A%3Cp%3EHere,%20method%20%3Cstrong%3E.times%3C/strong%3E%20sends%20a%20value%20to%20variable%20%3Cstrong%3E%7Ctime%7C%3C/strong%3E.%20But%20note%20that%20variable%20time%20is%20only%20known%20within%20the%20block.%3C/p%3E%0A%0A%3Cblockquote%3E%0A%3Cp%3EDid%20you%20notice%20that%20you%20can%20split%20code%20over%20multiple%20lines.%20This%20makes%20it%20a%20bit%20easier%20to%20read.%3C/p%3E%0A%3C/blockquote%3E%0A", "load_code": ""}, "31": {"lang": "EN", "title": "Now Arriving at Summary #4", "chapter": "Y", "answer": "", "ok": "", "error": "", "text": "%3Cp%3EThis%20last%20lesson%20was%20a%20bit%20longer.%20You’ve%20probably%20used%20up%20three%20minutes%20learning%20about:%3C/p%3E%0A%0A%3Ch3%3EHashes%3C/h3%3E%0A%0A%3Cp%3EThe%20little%20dictionary%20with%20the%20curly%20pages:%20%3Cstrong%3E%7B%7D%3C/strong%3E%3C/p%3E%0A%0A%3Ch3%3ESymbols%3C/h3%3E%0A%0A%3Cp%3ETiny,%20efficient%20code%20words%20with%20a%20colon,%20like:%20%3Cstrong%3E:splendid%3C/strong%3E%3C/p%3E%0A%0A%3Ch3%3EBlocks%3C/h3%3E%0A%0A%3Cp%3EChunks%20of%20code%20which%20can%20be%20tacked%20on%20to%20many%20of%20Ruby’s%20methods.%20Here’s%20the%20code%20you%20used%20to%0Abuild%20a%20scorecard:%3Cbr%3E%0A%3Cstrong%3Ebooks.values.each%20%7B%20%7Crate%7C%20ratings[rate]%20+=%201%20%7D%3C/strong%3E%3C/p%3E%0A%0A%3Ch3%3ENext%3C/h3%3E%0A%0A%3Cp%3EIn%20the%20next%20lesson%20we%20will%20delve%20al%20little%20bit%20deeper%20into%20methods.%3C/p%3E%0A", "load_code": ""}, - "32": {"lang": "EN", "title": "To (be) or not to (be)", "chapter": "N", "answer": "", "ok": "", "error": "", "text": "%3Cp%3EOne%20other%20little%20thing%20we%20haven’t%20really%20talked%20about%20openly:%20method%20arguments.%0ARemember%20when%20we%20changed%20the%20poem%20a%20little%20bit%20?%20We%20used:%3Cbr%3E%0A%3Cstrong%3Epoem.gsub(“toast”,%20“honeydew”)%3C/strong%3E%3C/p%3E%0A%0A%3Cp%3EThe%20gsub%20method%20needs%202%20arguments,%20which%20we%20passed%20to%20gsub%20by%20including%20two%20strings%20between%0Aparenthesis.%20%3Cem%3EArguments%20tell%20the%20method%20exactly%20what%20to%20do.%3C/em%3E%3C/p%3E%0A%0A%3Ch3%3EParenthesis%3C/h3%3E%0A%0A%3Cp%3EActually,%20most%20of%20the%20time%20Ruby%20doesn’t%20mind%20if%20you%20omit%20the%20parenthesis.%20So%20this%20would%20have%0Aworked%20too:%3Cbr%3E%0A%3Cstrong%3Epoem.gsub%20“toast”,%20“honeydew”%3C/strong%3E%3C/p%3E%0A%0A%3Cp%3EWe%20have%20already%20used%20another%20method%20with%20a%20parameter.%20Many%20times%20in%20fact,%20though%20it%20was%20not%20very%0Aobvious:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Eputs%20"Hello"%0Aputs("Hello")%0A%3C/code%3E%3C/pre%3E%0A%0A%3Cp%3EYes%20%3Cstrong%3Eputs%3C/strong%3E%20is%20also%20a%20method.%20Using%20puts%20with%20or%20without%20parenthesis%20is%20the%20same%20to%20Ruby,%20but%20the%0Aversion%20without%20parenthesis%20is%20a%20bit%20easier%20to%20read.%20And%20it%20saves%20you%20valuable%20typing%20time%20!%3C/p%3E%0A%0A%3Cblockquote%3E%0A%3Cp%3ESo%20I%20guess%20the%20conclusion%20is%20that%20you%20can%20do%20whatever%20you%20like%20with%20parenthesis%20as%20long%20as%20your%0Acode%20reads%20nicely.%3C/p%3E%0A%3C/blockquote%3E%0A%0A%3Ch3%3Eto%20(be)%20or%20not%20to%20(be)%3C/h3%3E%0A%0A%3Cp%3ESo%20if%20%3Cem%3Eto%3C/em%3E%20is%20a%20method%20and%20%3Cem%3Ebe%3C/em%3E%20is%20an%20argument%20we%20now%20know%20the%20answer%20to%20this%20age%20old%20question.%0AIt%20is%20really%20just%20a%20matter%20of%20preference%20whether%20you%20want%20%3Cem%3Eto%20be%3C/em%3E%20or%20%3Cem%3Eto(be)%3C/em%3E.%3C/p%3E%0A%0A%3Cp%3EAre%20you%20in%20the%20mood%20for%20more%20Shakespeare%20?%20Read%20on.%3C/p%3E%0A", "load_code": "poem%20=%20%22My%20toast%20has%20flown%20from%20my%20hand%5CnAnd%20my%20toast%20has%20gone%20to%20the%20moon.%5CnYada%20yada%20yada%5Cn%22"}, - "33": {"lang": "EN", "title": "The Taming of the Shrew", "chapter": "N", "answer": "%5Etame", "ok": "Good%20good%20!", "error": "", "text": "%3Cp%3EYou%20totally%20know%20how%20to%20use%20Ruby%20now.%20I%20mean%20you’ve%20got%20down%20the%20essentials.%0AYou%20just%20need%20to%20keep%20learning%20more%20methods%20and%20try%20out%20more%20complex%20blocks.%3C/p%3E%0A%0A%3Cp%3EBut%20there’s%20one%20side%20of%20Ruby%20we%20haven’t%20settled.%20Making%20your%20own%20methods.%0A%3Cstrong%3EAhem!%3C/strong%3E%20Let’s%20get%20it%20over%20with%20then.%3C/p%3E%0A%0A%3Cp%3ENext%20to%20using%20Ruby’s%20built%20in%20methods%20(like%20puts,%20sort,%20times)%20you%20can%20define%0Ayour%20own%20methods.%20Why%20is%20that%20a%20good%20idea?%20Two%20reasons:%3C/p%3E%0A%0A%3Ch3%3ETo%20make%20your%20program%20shorter%3C/h3%3E%0A%0A%3Cp%3EIf%20you%20have%20to%20do%20the%20same%20thing%20in%20more%20than%20one%20part%20of%20your%20code%20it%20is%20easier%0Ato%20put%20that%20code%20in%20a%20separate%20method.%20Your%20code%20will%20be%20shorter.%3C/p%3E%0A%0A%3Ch3%3ETo%20make%20your%20code%20easier%20to%20read%3C/h3%3E%0A%0A%3Cp%3ESuppose%20your%20program%20needs%20to%20do%20a%20lot%20of%20different%20things.%0AYou%20%3Cstrong%3Ecould%3C/strong%3E%20stuff%20all%20code%20into%20one%20long%20piece.%20But%20it%20would%20be%20very%20difficult%20to%0Aread%20and%20understand%20that%20code%20later.%3C/p%3E%0A%0A%3Cp%3EInstead%20you%20should%20cut%20up%20your%20code%20in%20different%20methods%20and%20give%20each%20method%20an%20easy%20to%0Aunderstand%20English%20name.%20You%20will%20thank%20yourself%20later.%3C/p%3E%0A%0A%3Cp%3ESo%20how%20do%20we%20define%20a%20method%20?%20Like%20this:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Edef%20tame(%20number_of_shrews%20)%0Aend%0A%3C/code%3E%3C/pre%3E%0A", "load_code": ""}, + "32": {"lang": "EN", "title": "To (be) or not to (be)", "chapter": "N", "answer": "", "ok": "", "error": "", "text": "%3Cp%3EOne%20other%20little%20thing%20we%20haven’t%20really%20talked%20about%20openly:%20method%20arguments.%0ARemember%20when%20we%20changed%20the%20poem%20a%20little%20bit?%20We%20used:%0A%3Cstrong%3Epoem.gsub(“toast”,%20“honeydew”)%3C/strong%3E%3C/p%3E%0A%0A%3Cp%3EThe%20gsub%20method%20needs%202%20arguments,%20which%20we%20passed%20to%20gsub%20by%20including%20two%20strings%20between%0Aparenthesis.%20%3Cem%3EArguments%20tell%20the%20method%20exactly%20what%20to%20do.%3C/em%3E%3C/p%3E%0A%0A%3Ch3%3EParenthesis%3C/h3%3E%0A%0A%3Cp%3EActually,%20most%20of%20the%20time%20Ruby%20doesn’t%20mind%20if%20you%20omit%20the%20parenthesis.%20So%20this%20would%20have%0Aworked%20too:%0A%3Cstrong%3Epoem.gsub%20“toast”,%20“honeydew”%3C/strong%3E%3C/p%3E%0A%0A%3Cp%3EWe%20have%20already%20used%20another%20method%20with%20a%20parameter.%20Many%20times%20in%20fact,%20though%20it%20was%20not%20very%0Aobvious:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Eputs%20"Hello"%0Aputs("Hello")%0A%3C/code%3E%3C/pre%3E%0A%0A%3Cp%3EYes%20%3Cstrong%3Eputs%3C/strong%3E%20is%20also%20a%20method.%20Using%20puts%20with%20or%20without%20parenthesis%20is%20the%20same%20to%20Ruby,%20but%20the%0Aversion%20without%20parenthesis%20is%20a%20bit%20easier%20to%20read.%20And%20it%20saves%20you%20valuable%20typing%20time!%3C/p%3E%0A%0A%3Cblockquote%3E%0A%3Cp%3ESo%20I%20guess%20the%20conclusion%20is%20that%20you%20can%20do%20whatever%20you%20like%20with%20parenthesis%20as%20long%20as%20your%0Acode%20reads%20nicely.%3C/p%3E%0A%3C/blockquote%3E%0A%0A%3Ch3%3Eto%20(be)%20or%20not%20to%20(be)%3C/h3%3E%0A%0A%3Cp%3ESo%20if%20%3Cem%3Eto%3C/em%3E%20is%20a%20method%20and%20%3Cem%3Ebe%3C/em%3E%20is%20an%20argument%20we%20now%20know%20the%20answer%20to%20this%20age%20old%20question.%0AIt%20is%20really%20just%20a%20matter%20of%20preference%20whether%20you%20want%20%3Cem%3Eto%20be%3C/em%3E%20or%20%3Cem%3Eto(be)%3C/em%3E.%3C/p%3E%0A%0A%3Cp%3EAre%20you%20in%20the%20mood%20for%20more%20Shakespeare?%20Read%20on.%3C/p%3E%0A", "load_code": "poem%20=%20%22My%20toast%20has%20flown%20from%20my%20hand%5CnAnd%20my%20toast%20has%20gone%20to%20the%20moon.%5CnYada%20yada%20yada%5Cn%22"}, + "33": {"lang": "EN", "title": "The Taming of the Shrew", "chapter": "N", "answer": "%5Etame", "ok": "Good%20good!", "error": "", "text": "%3Cp%3EYou%20totally%20know%20how%20to%20use%20Ruby%20now.%20I%20mean%20you’ve%20got%20down%20the%20essentials.%0AYou%20just%20need%20to%20keep%20learning%20more%20methods%20and%20try%20out%20more%20complex%20blocks.%3C/p%3E%0A%0A%3Cp%3EBut%20there’s%20one%20side%20of%20Ruby%20we%20haven’t%20settled.%20Making%20your%20own%20methods.%0A%3Cstrong%3EAhem!%3C/strong%3E%20Let’s%20get%20it%20over%20with%20then.%3C/p%3E%0A%0A%3Cp%3ENext%20to%20using%20Ruby’s%20built%20in%20methods%20(like%20puts,%20sort,%20times)%20you%20can%20define%0Ayour%20own%20methods.%20Why%20is%20that%20a%20good%20idea?%20Two%20reasons:%3C/p%3E%0A%0A%3Ch3%3ETo%20make%20your%20program%20shorter%3C/h3%3E%0A%0A%3Cp%3EIf%20you%20have%20to%20do%20the%20same%20thing%20in%20more%20than%20one%20part%20of%20your%20code%20it%20is%20easier%0Ato%20put%20that%20code%20in%20a%20separate%20method.%20Your%20code%20will%20be%20shorter.%3C/p%3E%0A%0A%3Ch3%3ETo%20make%20your%20code%20easier%20to%20read%3C/h3%3E%0A%0A%3Cp%3ESuppose%20your%20program%20needs%20to%20do%20a%20lot%20of%20different%20things.%0AYou%20%3Cstrong%3Ecould%3C/strong%3E%20stuff%20all%20code%20into%20one%20long%20piece.%20But%20it%20would%20be%20very%20difficult%20to%0Aread%20and%20understand%20that%20code%20later.%3C/p%3E%0A%0A%3Cp%3EInstead%20you%20should%20cut%20up%20your%20code%20in%20different%20methods%20and%20give%20each%20method%20an%20easy%20to%0Aunderstand%20English%20name.%20You%20will%20thank%20yourself%20later.%3C/p%3E%0A%0A%3Cp%3ESo%20how%20do%20we%20define%20a%20method?%20Like%20this:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Edef%20tame(%20number_of_shrews%20)%0Aend%0A%3C/code%3E%3C/pre%3E%0A", "load_code": ""}, "34": {"lang": "EN", "title": "In Ruby, Def Leppard means: define method Leppard", "chapter": "N", "answer": "%5Etame", "ok": "Tame%20is%20not%20lame", "error": "", "text": "%3Cp%3EHey,%20okay,%20you%20done%20it.%20You’re%20making%20your%20own%20method.%20You%20started%20with%20def,%20followed%20by%20the%20name%20of%20the%20method.%0AAnd%20a%20list%20of%20arguments%20which%20the%20method%20will%20need.%20This%20isn’t%20too%20scary%20and%20dangerous!%0AAll%20we%20have%20to%20do%20is%20fill%20it%20up%20with%20Ruby%20and%20finish%20it%20up%20with%20end.%3C/p%3E%0A%0A%3Cp%3EHere’s%20the%20code:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Edef%20tame(%20number_of_shrews%20)%0A%20%20number_of_shrews.times%20%7B%0A%20%20%20%20puts%20"Tamed%20a%20shrew"%0A%20%20%7D%0Aend%0A%3C/code%3E%3C/pre%3E%0A%0A%3Cblockquote%3E%0A%3Cp%3E%3Cstrong%3EP.S.%3C/strong%3E%3Cbr%3E%0AIf%20you%20don’t%20get%20the%20title%20of%20this%20chapter.%0A%3Ca%20href=%22http://en.wikipedia.org/wiki/Def_Leppard%22%20target=%22_blank%22%3EDef%20Leppard%3C/a%3E%0Ais%20the%20name%20of%20a,%20once%20famous,%20English%20rock%20band.%3C/p%3E%0A%3C/blockquote%3E%0A", "load_code": ""}, "35": {"lang": "EN", "title": "The Ripened Fruit of Your Own Creation", "chapter": "N", "answer": "%5ETamed%20a%20shrew", "ok": "That'll%20show%20those%20shrews", "error": "", "text": "%3Cp%3EA%20new%20method%20is%20born.%20Let%20us%20use%20it%20now:%20%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Etame%205%0A%3C/code%3E%3C/pre%3E%0A", "load_code": "def%20tame(number_of_shrews);number_of_shrews.times%7Bputs%20%22Tamed%20a%20shrew%22%7D;end;"}, - "36": {"lang": "EN", "title": "Give and take", "chapter": "N", "answer": "%5Cd+", "ok": "Right%20on.%20Bravo.", "error": "", "text": "%3Cp%3EMost%20methods%20do%20not%20only%20want%20some%20parameters%20as%20input,%20but%20will%20also%20%3Cstrong%3Egive%20something%20back%3C/strong%3E.%0AI%20have%20changed%20our%20method%20a%20bit%20so%20it%20will%20return%20a%20value%20to%20you.%20Try%20it:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Edef%20tame(%20number_of_shrews%20)%0A%20%20number_of_shrews.times%20%7B%0A%20%20%20%20puts%20"Tamed%20a%20shrew"%0A%20%20%7D%0A%20%20return%20number_of_shrews%0Aend%0A%0Aputs%20tame(3)%0A%3C/code%3E%3C/pre%3E%0A%0A%3Ch3%3EReturn%3C/h3%3E%0A%0A%3Cp%3EAnd,%20since%20you’re%20getting%20so%20advanced%20and%20capable%20here,%20one%20other%20tip:%0Ayou%20can%20omit%20the%20word%20%3Cstrong%3Ereturn%3C/strong%3E%20from%20the%20last%20line%20of%20the%20method.%0ARuby%20will%20automagically%20return%20the%20last%20value%20that%20was%20used%20inside%20the%20method.%3C/p%3E%0A%0A%3Cp%3ESo%20we%20can%20change%20the%20last%20line%20to%20just:%20%3Cstrong%3Enumber_of_shrews%3C/strong%3E.%3C/p%3E%0A%0A%3Cp%3EBut%20since%20method%20%3Cstrong%3E.times%3C/strong%3E%20also%20returns%20the%20%3Cem%3Enumber_of_shrews%3C/em%3E%20we%20can%0Aremove%20the%20entire%20last%20line.%20So%20in%20fact%20our%20original%20method%20already%20did%20what%20we%20wanted%20all%20along%20!%3C/p%3E%0A", "load_code": ""}, - "37": {"lang": "EN", "title": "Hello, Who's There? And Summary #5 Waves Its Hat!", "chapter": "Y", "answer": "", "ok": "", "error": "", "text": "%3Cp%3EWell%20done,%20well%20done,%20well%20done,%20well%20done!%3C/p%3E%0A%0A%3Cp%3ETruly,%20truly,%20truly,%20truly,%20truuuuuuuuly!%3C/p%3E%0A%0A%3Cp%3EHere’s%20the%20last%20few%20minutes%20of%20your%20life%20in%20review:%3C/p%3E%0A%0A%3Ch3%3EMethods%3C/h3%3E%0A%0A%3Cp%3EMethods%20can%20be%20defined%20with%20%3Cstrong%3Edef%3C/strong%3E%20and%20have%20a%20name.%20Methods%20make%20your%20program%20shorter%0Aand%20easier%20to%20read.%3C/p%3E%0A%0A%3Ch3%3EParameters%3C/h3%3E%0A%0A%3Cp%3EMethods%20can%20have%20parameters.%3C/p%3E%0A%0A%3Ch3%3EReturn%20values%3C/h3%3E%0A%0A%3Cp%3EMethods%20(almost)%20always%20return%20a%20value.%3C/p%3E%0A%0A%3Ch2%3ENow%3C/h2%3E%0A%0A%3Cp%3ETo%20(be)%20or%20not%20to%20(be)%20is%20not%20a%20question%20to%20you%20anymore.%20Are%20you%20ready%20for%20some%20more%20Shakespeare%20?%3C/p%3E%0A", "load_code": ""}, + "36": {"lang": "EN", "title": "Give and take", "chapter": "N", "answer": "%5Cd+", "ok": "Right%20on.%20Bravo.", "error": "", "text": "%3Cp%3EMost%20methods%20do%20not%20only%20want%20some%20parameters%20as%20input,%20but%20will%20also%20%3Cstrong%3Egive%20something%20back%3C/strong%3E.%0AI%20have%20changed%20our%20method%20a%20bit%20so%20it%20will%20return%20a%20value%20to%20you.%20Try%20it:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Edef%20tame(%20number_of_shrews%20)%0A%20%20number_of_shrews.times%20%7B%0A%20%20%20%20puts%20"Tamed%20a%20shrew"%0A%20%20%7D%0A%20%20return%20number_of_shrews%0Aend%0A%0Aputs%20tame(3)%0A%3C/code%3E%3C/pre%3E%0A%0A%3Ch3%3EReturn%3C/h3%3E%0A%0A%3Cp%3EAnd,%20since%20you’re%20getting%20so%20advanced%20and%20capable%20here,%20one%20other%20tip:%0Ayou%20can%20omit%20the%20word%20%3Cstrong%3Ereturn%3C/strong%3E%20from%20the%20last%20line%20of%20the%20method.%0ARuby%20will%20automagically%20return%20the%20last%20value%20that%20was%20used%20inside%20the%20method.%3C/p%3E%0A%0A%3Cp%3ESo%20we%20can%20change%20the%20last%20line%20to%20just:%20%3Cstrong%3Enumber_of_shrews%3C/strong%3E.%3C/p%3E%0A%0A%3Cp%3EBut%20since%20method%20%3Cstrong%3E.times%3C/strong%3E%20also%20returns%20the%20%3Cem%3Enumber_of_shrews%3C/em%3E%20we%20can%0Aremove%20the%20entire%20last%20line.%20So%20in%20fact%20our%20original%20method%20already%20did%20what%20we%20wanted%20all%20along!%3C/p%3E%0A", "load_code": ""}, + "37": {"lang": "EN", "title": "Hello, Who's There? And Summary #5 Waves Its Hat!", "chapter": "Y", "answer": "", "ok": "", "error": "", "text": "%3Cp%3EWell%20done,%20well%20done,%20well%20done,%20well%20done!%3C/p%3E%0A%0A%3Cp%3ETruly,%20truly,%20truly,%20truly,%20truuuuuuuuly!%3C/p%3E%0A%0A%3Cp%3EHere’s%20the%20last%20few%20minutes%20of%20your%20life%20in%20review:%3C/p%3E%0A%0A%3Ch3%3EMethods%3C/h3%3E%0A%0A%3Cp%3EMethods%20can%20be%20defined%20with%20%3Cstrong%3Edef%3C/strong%3E%20and%20have%20a%20name.%20Methods%20make%20your%20program%20shorter%0Aand%20easier%20to%20read.%3C/p%3E%0A%0A%3Ch3%3EParameters%3C/h3%3E%0A%0A%3Cp%3EMethods%20can%20have%20parameters.%3C/p%3E%0A%0A%3Ch3%3EReturn%20values%3C/h3%3E%0A%0A%3Cp%3EMethods%20(almost)%20always%20return%20a%20value.%3C/p%3E%0A%0A%3Ch2%3ENow%3C/h2%3E%0A%0A%3Cp%3ETo%20(be)%20or%20not%20to%20(be)%20is%20not%20a%20question%20to%20you%20anymore.%20Are%20you%20ready%20for%20some%20more%20Shakespeare?%3C/p%3E%0A", "load_code": ""}, "38": {"lang": "EN", "title": "The world is our oyster", "chapter": "N", "answer": "%5E%5C%7B%5C%22William", "ok": "Good.%20Bit%20difficult%20to%20read.", "error": "", "text": "%3Cp%3ESo%20far%20we%20have%20been%20running%20programs%20that%20only%20use%20things%20that%20we%20have%20typed%20ourselves.%0AWhich%20is%20nice,%20I%20mean%20that%20%3Cem%3EOdelaying%3C/em%3E%20was%20epic,%20but%20this%20the%20internet%20era%20so%20it%20is%20about%0Atime%20we%20included%20the%20rest%20of%20the%20world%20in%20our%20programming%20efforts.%3C/p%3E%0A%0A%3Cp%3EMany,%20many,%20many%20websites%20are%20available%20that%20you%20can%20ask%20for%20information.%20For%20instance%0Athis%20link%20will%20give%20you%20all%20current%20%3Ca%20href=%22http://news.google.com/news/section?q=ruby&output=rss%22%20target=%22_blank%22%3EGoogle%20news%20feeds%3C/a%3E%0Aabout%20Ruby.%3C/p%3E%0A%0A%3Cp%3EYour%20web%20browser%20will%20probably%20display%20it%20quite%20nicely%20for%20you.%20If%20you%20look%20at%20the%20source%0A(type:%20control-U)%20you%20will%20see%20a%20long%20string%20of%20strangely%20formatted%20text.%20In%20the%20Google%20example%0Ait%20is%20in%20the%20%3Cstrong%3Erss%3C/strong%3E%20format.%3C/p%3E%0A%0A%3Ch3%3EFormats%3C/h3%3E%0A%0A%3Cp%3EThere%20are%20many%20other%20formats,%20with%20strange%20names,%20available%20and%20used%20on%20the%20web,%20like:%0Ahtml,%20xml%20and%20json.%20Yes,%20even%20this%20very%20website%20uses%20a%20couple%20of%20these.%3C/p%3E%0A%0A%3Cp%3EI%20have%20prepared%20a%20method%20for%20you%20that%20will%20fetch%20a%20list%20of%20the%20complete%20works%20of%20William%0AShakespeare%20from%20the%20internet.%0A(Don’t%20worry%20it%20actually%20comes%20from%20the%20same%20server%20that%20this%20website%20runs%20on,%20so%0Awe’re%20not%20bothering%20anyone.)%3C/p%3E%0A%0A%3Cp%3EGet%20the%20data%20with:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Eget_shakey%0A%3C/code%3E%3C/pre%3E%0A", "load_code": "def%20get_shakey;JSON.parse(%22%7B%5C%22William%20Shakespeare%5C%22:%20%7B%5C%221%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22The%20Two%20Gentlemen%20of%20Verona%5C%22,%20%5C%22finished%5C%22:%201591%7D,%5C%222%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22The%20Taming%20of%20the%20Shrew%5C%22,%20%5C%22finished%5C%22:%201591%7D,%5C%223%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22Henry%20VI,%20Part%202%5C%22,%20%5C%22finished%5C%22:%201591%7D,%5C%224%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22Henry%20VI,%20Part%203%5C%22,%20%5C%22finished%5C%22:%201591%7D,%5C%225%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22Henry%20VI,%20Part%201%5C%22,%20%5C%22finished%5C%22:%201592%7D,%5C%226%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22Titus%20Andronicus%5C%22,%20%5C%22finished%5C%22:%201592%7D,%5C%227%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22Richard%20III%5C%22,%20%5C%22finished%5C%22:%201593%7D,%5C%228%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22Edward%20III%5C%22,%20%5C%22finished%5C%22:%201593%7D,%5C%229%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22The%20Comedy%20of%20Errors%5C%22,%20%5C%22finished%5C%22:%201594%7D,%5C%2210%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22Love's%20Labour's%20Lost%5C%22,%20%5C%22finished%5C%22:%201595%7D,%5C%2211%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22Love's%20Labour's%20Won%5C%22,%20%5C%22finished%5C%22:%201596%7D,%5C%2212%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22Richard%20II%5C%22,%20%5C%22finished%5C%22:%201595%7D,%5C%2213%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22Romeo%20and%20Juliet%5C%22,%20%5C%22finished%5C%22:%201595%7D,%5C%2214%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22A%20Midsummer%20Night's%20Dream%5C%22,%20%5C%22finished%5C%22:%201595%7D,%5C%2215%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22King%20John%5C%22,%20%5C%22finished%5C%22:%201596%7D,%5C%2216%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22The%20Merchant%20of%20Venice%5C%22,%20%5C%22finished%5C%22:%201597%7D,%5C%2217%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22Henry%20IV,%20Part%201%5C%22,%20%5C%22finished%5C%22:%201597%7D,%5C%2218%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22The%20Merry%20Wives%20of%20Windsor%5C%22,%20%5C%22finished%5C%22:%201597%7D,%5C%2219%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22Henry%20IV,%20Part%202%5C%22,%20%5C%22finished%5C%22:%201598%7D,%5C%2220%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22Much%20Ado%20About%20Nothing%5C%22,%20%5C%22finished%5C%22:%201599%7D,%5C%2221%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22Henry%20V%5C%22,%20%5C%22finished%5C%22:%201599%7D,%5C%2222%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22Julius%20Caesar%5C%22,%20%5C%22finished%5C%22:%201599%7D,%5C%2223%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22As%20You%20Like%20It%5C%22,%20%5C%22finished%5C%22:%201600%7D,%5C%2224%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22Hamlet%5C%22,%20%5C%22finished%5C%22:%201601%7D,%5C%2225%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22Twelfth%20Night%5C%22,%20%5C%22finished%5C%22:%201601%7D,%5C%2226%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22Troilus%20and%20Cressida%5C%22,%20%5C%22finished%5C%22:%201602%7D,%5C%2227%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22Sir%20Thomas%20More%5C%22,%20%5C%22finished%5C%22:%201604%7D,%5C%2228%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22Measure%20for%20Measure%5C%22,%20%5C%22finished%5C%22:%201604%7D,%5C%2229%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22Othello%5C%22,%20%5C%22finished%5C%22:%201604%7D,%5C%2230%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22All's%20Well%20That%20Ends%20Well%5C%22,%20%5C%22finished%5C%22:%201605%7D,%5C%2231%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22King%20Lear%5C%22,%20%5C%22finished%5C%22:%201606%7D,%5C%2232%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22Timon%20of%20Athens%5C%22,%20%5C%22finished%5C%22:%201606%7D,%5C%2233%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22Macbeth%5C%22,%20%5C%22finished%5C%22:%201606%7D,%5C%2234%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22Antony%20and%20Cleopatra%5C%22,%20%5C%22finished%5C%22:%201606%7D,%5C%2235%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22Pericles,%20Prince%20of%20Tyre%5C%22,%20%5C%22finished%5C%22:%201608%7D,%5C%2236%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22Coriolanus%5C%22,%20%5C%22finished%5C%22:%201608%7D,%5C%2237%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22The%20Winter's%20Tale%5C%22,%20%5C%22finished%5C%22:%201611%7D,%5C%2238%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22Cymbeline%5C%22,%20%5C%22finished%5C%22:%201610%7D,%5C%2239%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22The%20Tempest%5C%22,%20%5C%22finished%5C%22:%201611%7D,%5C%2240%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22Cardenio%5C%22,%20%5C%22finished%5C%22:%201613%7D,%5C%2241%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22Henry%20VIII%5C%22,%20%5C%22finished%5C%22:%201613%7D,%5C%2242%5C%22:%20%7B%5C%22title%5C%22:%20%5C%22The%20Two%20Noble%20Kinsmen%5C%22,%20%5C%22finished%5C%22:%201614%7D%7D%7D%22);end;"}, "39": {"lang": "EN", "title": "Noble Kinsmen", "chapter": "N", "answer": "%5EThe%20Two%20Noble%20Kinsmen$", "ok": "That's%20much%20better", "error": "", "text": "%3Cp%3EOkay%20we%20now%20have%20a%20list%20of%20plays%20from%20the%20internet.%20The%20list%20was%20in%20the%20json%20format.%0AFortunately%20for%20us%20Ruby%20kindly%20provides%20a%20method%20to%20convert%20json%20data%20to%20a%20Ruby%20hash.%0AThe%20%3Cem%3Eget_shakey%3C/em%3E%20method%20already%20did%20that%20for%20us.%3C/p%3E%0A%0A%3Cp%3EBut%20since%20the%20structure%20of%20the%20json%20data%20is%20retained%20in%20the%20hash,%20it%20is%20still%20a%20bit%20difficult%20to%20read.%0ALet%20us%20write%20a%20method%20to%20display%20the%20plays%20nicely.%3C/p%3E%0A%0A%3Cp%3EIf%20you%20inspect%20the%20list%20of%20plays%20carefully%20you%20will%20see%20that%20it%20has%20a%20kind%20of%20nested%0Astructure.%20(This%20is%20actually%20quite%20common%20in%20data%20you%20get%20from%20the%20internet.)%0ALooks%20like%20this:%3C/p%3E%0A%0A%3Cul%3E%0A%20%20%3Cli%3E“William%20Shakespeare”%0A%20%20%3Cul%3E%0A%20%20%20%20%20%20%3Cli%3E“1”%0A%20%20%20%20%20%20%3Cul%3E%0A%20%20%20%20%20%20%20%20%3Cli%3E“title”:%20“The%20Two%20Gentlemen%20of%20Verona”%3C/li%3E%0A%20%20%20%20%20%20%20%20%3Cli%3E“finished”:%201591%3C/li%3E%0A%20%20%20%20%20%20%3C/ul%3E%0A%20%20%20%20%20%20%3C/li%3E%0A%20%20%20%20%20%20%3Cli%3E“2”%0A%20%20%20%20%20%20%3Cul%3E%0A%20%20%20%20%20%20%20%20%3Cli%3E“title”:%20“The%20Taming%20of%20the%20Shrew”%3C/li%3E%0A%20%20%20%20%20%20%20%20%3Cli%3E“finished”:%201591%3C/li%3E%0A%20%20%20%20%20%20%3C/ul%3E%0A%20%20%20%20%20%20%3C/li%3E%0A%20%20%20%20%20%20%3Cli%3E…%3C/li%3E%0A%20%20%3C/ul%3E%0A%20%20%3C/li%3E%0A%3C/ul%3E%0A%0A%3Cp%3ETo%20list%20the%20plays%20we%20first%20have%20to%20access%20the%20top%20“William%20Shakespeare”%20hash%20element%20by%20it’s%20name.%0ANext%20we%20have%20to%20%3Cstrong%3Eiterate%3C/strong%3E%20through%20each%20element%20below%20it.%3C/p%3E%0A%0A%3Cp%3ERuby%20has%20a%20method%20for%20iterating.%20It%20is%20called%20%3Cstrong%3Eeach%3C/strong%3E.%20We%20have%20seen%20it%20before%20when%0Acreating%20our%20book%20rating%20system.%3C/p%3E%0A%0A%3Cp%3EEverything%20that%20method%20%3Cstrong%3Eeach%3C/strong%3E%20returns%20is%20passed%20to%20a%20block:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Es%20=%20get_shakey%0A%0As["William%20Shakespeare"].each%20%7B%20%7Ckey,%20val%7C%0A%20%20puts%20val["title"]%0A%7D%0A%3C/code%3E%3C/pre%3E%0A", "load_code": "prev"}, "40": {"lang": "EN", "title": "All together now", "chapter": "N", "answer": "%5E4$", "ok": "Yes,%20Shakespeare%20wrote%204%20plays%20in%201591", "error": "Answer%20for%20the%20year%201591%20should%20be%204", "text": "%3Cp%3ENow%20suppose%20we%20only%20want%20to%20know%20the%20names%20and%20number%20of%20plays%20written%20by%20Shakespeare%0Ain%20a%20certain%20year.%3C/p%3E%0A%0A%3Cp%3ERuby%20lets%20us%20%3Cstrong%3Eselect%3C/strong%3E%20values%20from%20a%20hash.%20The%20select%20method%20uses%20a%20block%20to%20let%20us%0Adefine%20what%20to%20select%20and%20returns%20what%20it%20found.%3C/p%3E%0A%0A%3Cp%3EWe%20can%20then%20use%20the%20results%20returned%20by%20%3Cstrong%3Eselect%3C/strong%3E%20in%20the%20%3Cstrong%3Eeach%3C/strong%3E%20method%20as%20before%20by%0Asimply%20adding%20it%20after%20the%20select%20block.%20This%20is%20another%20example%20of%20method%20chaining,%20which%20we%20saw%0Aearlier%20when%20reversing%20a%20poem.%3C/p%3E%0A%0A%3Cp%3EI%20have%20prepared%20the%20%3Cstrong%3Ecount_plays%3C/strong%3E%20method%20for%20you.%20See%20if%20you%20can%20find%20out%20how%20many%20plays%0Awere%20written%20by%20Shakespeare%20in%20the%20year%20%3Cstrong%3E1591%3C/strong%3E.%20Try%20this:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Edef%20count_plays(year)%0A%20%20s%20=%20get_shakey%0A%0A%20%20s["William%20Shakespeare"]%0A%20%20%20%20.select%20%7B%20%7Ck,%20v%7C%0A%20%20%20%20%20%20v["finished"]%20==%20year%0A%20%20%20%20%7D.each%20%7B%20%7Ckey,%20val%7C%0A%20%20%20%20%20%20puts%20val["title"]%0A%20%20%20%20%7D.count%0Aend%0A%0Aputs%20count_plays(0)%0A%3C/code%3E%3C/pre%3E%0A%0A%3Cp%3EDid%20you%20notice%20that%20I%20chained%20the%20count%20method%20at%20the%20end%20of%20the%20each%20method.%20This%20gives%0Aus%20a%20return%20value%20for%20the%20%3Cstrong%3Ecount_plays%3C/strong%3E%20method.%3C/p%3E%0A%0A%3Cp%3EThere%20is%20another%20possibility%20for%20chaining%20here.%20See%20that%20loney%20line%20%3Cstrong%3Es%20=%20get_shakey%3C/strong%3E.%0AYou%20could%20add%20the%20%3Cstrong%3E[“William%20Shakespeare”].select%20%7B%20%7Ck,%20v%7C%3C/strong%3E%20at%20the%20end%20of%20get_shakey%0A(no%20dot%20needed%20in%20this%20case).%3C/p%3E%0A", "load_code": "prev"}, - "41": {"lang": "EN", "title": "All's Well That Ends Well", "chapter": "N", "answer": "All's%20Well%20That%20Ends%20Well", "ok": "True", "error": "Use%201605%20as%20the%20second%20parameter", "text": "%3Cp%3EOkay,%20we%20got%20some%20data%20from%20the%20internet,%20we%20selected%20what%20we%20wanted%20and%20printed%20it%20out.%0AWhat%20is%20left%20to%20improve?%20We%20could%20print%20the%20results%20a%20bit%20prettier.%20Like%20add%20the%20year%0Aand%20align%20titles%20and%20years.%3C/p%3E%0A%0A%3Cp%3EThis%20means%20printing%20several%20values%20on%20one%20line.%20Ruby%20has%20a%20neat%20way%20of%20doing%0Athat.%20It%20is%20just%20like%20printing%20a%20string%20like:%20%3Cstrong%3Eputs%20“Hi,%20my%20name%20is%20Jimmy”%3C/strong%3E.%0ABut%20instead%20of%20the%20literal%20value%20%3Cem%3EJimmy%3C/em%3E%20we%20use%20the%20value%20of%20a%20variable.%3C/p%3E%0A%0A%3Cp%3EFirst%20replace%20%3Cstrong%3EJimmy%3C/strong%3E%20with%20%3Cstrong%3E%23%7B%7D%3C/strong%3E.%20If%20Ruby%20sees%20a%20hash%20symbol%20%23%20followed%20by%20a%20curly%20brace%20%7B%0Ait%20looks%20for%20a%20variable%20between%20the%20first%20brace%20and%20the%20following%20closing%20brace%20%7D.%0ASo%20we%20can%20use%20this:%20%3Cstrong%3E“Hi,%20my%20name%20is%20%23%7Bname%7D”%3C/strong%3E.%3C/p%3E%0A%0A%3Cp%3ELet’s%20change%20our%20code%20a%20bit%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Edef%20print_plays(year_from,%20year_to)%0A%20%20get_shakey["William%20Shakespeare"]%0A%20%20%20%20.select%20%7B%20%7Ck,%20v%7C%0A%20%20%20%20%20%20year_from%20<=%20v["finished"]%20&&%0A%20%20%20%20%20%20year_to%20%20%20>=%20v["finished"]%0A%20%20%20%20%7D.each%20%7B%20%7Ck,%20v%7C%0A%20%20%20%20%20%20puts%20"%23%7Bv["title"].ljust(30)%7D%20%23%7Bv["finished"]%7D"%0A%20%20%20%20%7D%0Aend%0Aprint_plays(1600,%201605)%0A%3C/code%3E%3C/pre%3E%0A%0A%3Cp%3EI%20have%20added%20%3Cstrong%3E.ljust(30)%3C/strong%3E%20to%20the%20title.%20This%20way%20the%20title%20is%20%3Cem%3Eleft%20justified%3C/em%3E%20with%20a%20minimum%0Alength%20of%2030%20characters%20so%20the%20years%20align%20nicely.%3C/p%3E%0A%0A%3Cp%3ESee%20if%20you%20can%20change%20the%20ouput%20of%20the%20program%20so%20that%20it%20shows%20the%20plays%20like%20this:%20%3Cstrong%3E1600%20->%20As%20You%20Like%20It%3C/strong%3E%3C/p%3E%0A%0A%3Cp%3E%3Cstrong%3EAll’s%20Well%20That%20Ends%20Well%20?%3C/strong%3E%20Hey%20we’re%20not%20done%20yet,%20but%20the%20end%20is%20in%20sight%20!%3C/p%3E%0A", "load_code": "prev"}, + "41": {"lang": "EN", "title": "All's Well That Ends Well", "chapter": "N", "answer": "All's%20Well%20That%20Ends%20Well", "ok": "True", "error": "Use%201605%20as%20the%20second%20parameter", "text": "%3Cp%3EOkay,%20we%20got%20some%20data%20from%20the%20internet,%20we%20selected%20what%20we%20wanted%20and%20printed%20it%20out.%0AWhat%20is%20left%20to%20improve?%20We%20could%20print%20the%20results%20a%20bit%20prettier.%20Like%20add%20the%20year%0Aand%20align%20titles%20and%20years.%3C/p%3E%0A%0A%3Cp%3EThis%20means%20printing%20several%20values%20on%20one%20line.%20Ruby%20has%20a%20neat%20way%20of%20doing%0Athat.%20It%20is%20just%20like%20printing%20a%20string%20like:%20%3Cstrong%3Eputs%20“Hi,%20my%20name%20is%20Jimmy”%3C/strong%3E.%0ABut%20instead%20of%20the%20literal%20value%20%3Cem%3EJimmy%3C/em%3E%20we%20use%20the%20value%20of%20a%20variable.%3C/p%3E%0A%0A%3Cp%3EFirst%20replace%20%3Cstrong%3EJimmy%3C/strong%3E%20with%20%3Cstrong%3E%23%7B%7D%3C/strong%3E.%20If%20Ruby%20sees%20a%20hash%20symbol%20%23%20followed%20by%20a%20curly%20brace%20%7B%0Ait%20looks%20for%20a%20variable%20between%20the%20first%20brace%20and%20the%20following%20closing%20brace%20%7D.%0ASo%20we%20can%20use%20this:%20%3Cstrong%3E“Hi,%20my%20name%20is%20%23%7Bname%7D”%3C/strong%3E.%3C/p%3E%0A%0A%3Cp%3ELet’s%20change%20our%20code%20a%20bit%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Edef%20print_plays(year_from,%20year_to)%0A%20%20get_shakey["William%20Shakespeare"]%0A%20%20%20%20.select%20%7B%20%7Ck,%20v%7C%0A%20%20%20%20%20%20year_from%20<=%20v["finished"]%20&&%0A%20%20%20%20%20%20year_to%20%20%20>=%20v["finished"]%0A%20%20%20%20%7D.each%20%7B%20%7Ck,%20v%7C%0A%20%20%20%20%20%20puts%20"%23%7Bv["title"].ljust(30)%7D%20%23%7Bv["finished"]%7D"%0A%20%20%20%20%7D%0Aend%0Aprint_plays(1600,%201605)%0A%3C/code%3E%3C/pre%3E%0A%0A%3Cp%3EI%20have%20added%20%3Cstrong%3E.ljust(30)%3C/strong%3E%20to%20the%20title.%20This%20way%20the%20title%20is%20%3Cem%3Eleft%20justified%3C/em%3E%20with%20a%20minimum%0Alength%20of%2030%20characters%20so%20the%20years%20align%20nicely.%3C/p%3E%0A%0A%3Cp%3ESee%20if%20you%20can%20change%20the%20ouput%20of%20the%20program%20so%20that%20it%20shows%20the%20plays%20like%20this:%20%3Cstrong%3E1600%20->%20As%20You%20Like%20It%3C/strong%3E%3C/p%3E%0A%0A%3Cp%3E%3Cstrong%3EAll’s%20Well%20That%20Ends%20Well?%3C/strong%3E%20Hey%20we’re%20not%20done%20yet,%20but%20the%20end%20is%20in%20sight!%3C/p%3E%0A", "load_code": "prev"}, "42": {"lang": "EN", "title": "If only I new how to make a decision", "chapter": "N", "answer": "", "ok": "", "error": "", "text": "%3Cp%3EDecision%20making,%20in%20real%20life%20this%20can%20be%20a%20real%20problem.%20Not%20for%20us%20though.%0ARuby%20makes%20it%20very%20easy%20to%20make%20decisions.%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Eif%201%20<%202%0A%20%20puts%20"It%20is%20true:%201%20is%20less%20than%202"%0Aend%0A%3C/code%3E%3C/pre%3E%0A%0A%3Cp%3EThe%20key%20word%20here%20is%20%3Cstrong%3Eif%3C/strong%3E.%20If%20can%20be%20placed%20before%20a%20method%20or%20after%20a%20method,%20like%20so:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Eputs%20"It%20is%20true:%201%20is%20less%20than%202"%20if%201%20<%202%0A%3C/code%3E%3C/pre%3E%0A%0A%3Cp%3E%3Cstrong%3EIf%3C/strong%3E%20is%20a%20method%20that%20requires%20one%20parameter.%20That%20parameter%20can%20be%20any%20expression%20that%20you%0Awant%20to%20test.%20The%20outcome%20of%20the%20expression%20must%20be%20either%20%3Cstrong%3Etrue%3C/strong%3E%20or%20%3Cstrong%3Efalse%3C/strong%3E.%0AHere%20are%20a%20couple%20of%20expressions%20with%20their%20outcomes:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3E5%20%20%20%20%20<=%2010%20%20%20%20%20%23%20=>%20true%0A&%2339;abc&%2339;%20==%20&%2339;def&%2339;%20%20%23%20=>%20false%0Atrue%20%20%20%20%20%20%20%20%20%20%20%20%23%20=>%20true%0A123456%20%20%20%20%20%20%20%20%20%20%23%20=>%20true%0A0%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20=>%20true%0Anil%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20=>%20false%0A&%2339;xyz&%2339;.empty?%20%20%20%20%23%20=>%20false%0A&%2339;a&%2339;%20>%205%20%20%20%20%20%20%20%20%20%23%20=>%20error:%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20comparison%20of%20String%20with%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20Numeric%20failed%0A%3C/code%3E%3C/pre%3E%0A%0A%3Cp%3EThe%20%3Cem%3Eif%20expression%3C/em%3E%20can%20take%20many%20forms.%20It%20can%20compare%20literal%20values%20(1%20<%202),%0Avariables%20(a%20<%201)%20and%20the%20return%20value%20of%20a%20method%20(‘xyz’.empty?).%3C/p%3E%0A", "load_code": ""}, "43": {"lang": "EN", "title": "And Now For the Startling Conclusion", "chapter": "N", "answer": "is%20not%20equal%20to%20100$", "ok": "That's%20better", "error": "This%20can't%20be%20right", "text": "%3Cp%3EDid%20you%20see%20the%202%20equal%20signs%20in%20%3Cstrong%3E‘abc’%20==%20‘def’%3C/strong%3E?%3C/p%3E%0A%0A%3Cp%3EThis%20%3Cstrong%3E==%3C/strong%3E%20means%20%3Cstrong%3Eis%20equal%20to%3C/strong%3E.%0AThe%20single%20equal%20sign%20that%20we%20have%20seen%20before%20means%20%3Cstrong%3Eassign%20a%20value%20to%20a%20variable%3C/strong%3E.%3C/p%3E%0A%0A%3Cp%3ETo%20make%20it%20more%20confusing:%20you%20can%20use%20the%20assignment%20after%20an%20if%20method%20like%20this:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Ea%20=%200%0A%0Aif%20a%20=%20100%0A%20%20puts%20"Expression%20is%20true,%20but%20a%20is%20now:%20%23%7Ba%7D"%0Aelse%0A%20%20puts%20"%23%7Ba%7D%20is%20not%20equal%20to%20100"%0Aend%0A%3C/code%3E%3C/pre%3E%0A%0A%3Cp%3EChange%20the%20=%20into%20==%20and%20see%20what%20happens.%3C/p%3E%0A%0A%3Cp%3EI%20can%20guarantee%20you%20that%20you%20will%20forget%20typing%20the%20second%20equal%20sign%20regularly.%20I%20also%0Astill%20forget%20it%20sometimes.%3C/p%3E%0A%0A%3Ch3%3Eelse%3C/h3%3E%0A%0A%3Cp%3EIn%20the%20code%20above%20I%20have%20added%20an%20else%20expression.%20This%20part%20will%20be%20executed%20when%20the%0A%3Cstrong%3Eif%20test-expression%3C/strong%3E%20evaluates%20to%20false.%3C/p%3E%0A%0A%3Cblockquote%3E%0A%3Cp%3EThere%20are%20more%20variations%20to%20this%20if-then-else%20theme.%20You%20can%20read%20more%0A%3Ca%20href=%22http://www.ruby-doc.org/core/doc/syntax/control_expressions_rdoc.html%22%20target=%22_blank%22%3Ehere%3C/a%3E.%3C/p%3E%0A%3C/blockquote%3E%0A", "load_code": ""}, - "44": {"lang": "EN", "title": "Me hungry", "chapter": "N", "answer": "%5EMe%20not%20hungry.$", "ok": "Yes", "error": "No%20way%20am%20I%20hungry%20at%2010%20AM%20!", "text": "%3Cp%3EOkay,%20this%20is%20coming%20along%20wonderfully.%20This%20is%20simple%20stuff%20for%20you,%20but%20keep%20in%20mind%20that%20you%0Adidn’t%20know%20%3Cstrong%3Eany%20Ruby%20whatsoever%3C/strong%3E%20just%20fifteen%20minutes%20ago!%3C/p%3E%0A%0A%3Cp%3ELast%20step.%20Let’s%20tie%20it%20all%20together,%20you%20know?%20Let’s%20make%20it%20chime%20together%20like%20a%20very%20nice%20set%0Aof%20glistening%20chimes%20on%20the%20beach%20in%20the%20maginificent%20sunlight!%3C/p%3E%0A%0A%3Cp%3EWe’ll%20define%20two%20methods%20first%20and%20then%20take%20a%20decision:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Edef%20hungry?(time_of_day_in_hours)%0A%20%20puts%20"Me%20hungry."%0A%20%20true%0Aend%0A%0Adef%20eat_an(what)%0A%20%20puts%20"Me%20eat%20%23%7Bwhat%7D.%5Cn"%0Aend%0A%0Aeat_an%20&%2339;apple&%2339;%20if%20hungry?(14)%0A%0Aeat_an%20&%2339;apple&%2339;%20if%20hungry?(10)%0A%3C/code%3E%3C/pre%3E%0A%0A%3Cp%3ENow%20see%20if%20you%20can%20change%20the%20method%20%3Cstrong%3Ehungry?%3C/strong%3E%20to%20display%20%3Cstrong%3E“Me%20not%20hungry”%3C/strong%3E%20and%20returning%20false%0Awhen%20the%20time%20is%20less%20than%2012.%3C/p%3E%0A", "load_code": ""}, - "45": {"lang": "EN", "title": "Summary #6 Which Means You've Come So Far", "chapter": "Y", "answer": "%5C%7B%5C%7D", "ok": "Ok,%20that's%20an%20empty%20hash", "error": "", "text": "%3Cp%3EYou’re%20a%20level%20six%20Ruby%20cleric.%20I%20mean%20what%20a%20great%20job%20you’ve%20done.%20Let’s%20review:%3C/p%3E%0A%0A%3Ch3%3EData%3C/h3%3E%0A%0A%3Cp%3EYou%20loaded%20some%20data%20of%20the%20internet,%20traversed%20a%20data%20structure%20and%20selected%20values.%3C/p%3E%0A%0A%3Ch3%3EIterating%3C/h3%3E%0A%0A%3Cp%3EYou%20iterated%20all%20elements%20of%20a%20hash%20and%20you%20chained%20some%20more%20methods.%3C/p%3E%0A%0A%3Ch3%3EPretty%20printing%3C/h3%3E%0A%0A%3Cp%3EAnd%20if%20that%20wasn’t%20enough,%20you%20formatted%20and%20printed%20some%20values%20in%20a%20way%20that%20is%20easy%0Ato%20read%20for%20humans.%20In%20fact%20%3Cstrong%3Eyou%20made%20a%20real%20program%20!%3C/strong%3E%3C/p%3E%0A%0A%3Ch3%3EIF%3C/h3%3E%0A%0A%3Cp%3EYou%20learned%20to%20take%20control%20of%20your%20programs%20with%20%3Cstrong%3Eif%3C/strong%3E%20and%20%3Cstrong%3Eelse%3C/strong%3E%20statements.%3C/p%3E%0A%0A%3Ch2%3ESo%3C/h2%3E%0A%0A%3Cp%3EWhat%20could%20possibly%20be%20next?%20What%20could%20you%20possibly%20have%20to%20learn%20now?%0AHa,%20this%20is%20the%20best%20part.%20You’ve%20come%20such%20a%20long%20way%20that%20we’re%20going%0Ato%20uncover%20classes.%20For%20two%20more%20short%20lessons%20and%20you’re%20done.%3C/p%3E%0A%0A%3Cp%3EEarlier,%20we%20created%20a%20hash%20like%20this:%20%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3EHash.new%0A%3C/code%3E%3C/pre%3E%0A", "load_code": ""}, - "46": {"lang": "EN", "title": "Not a School Class, a Working Class", "chapter": "N", "answer": "", "ok": "", "error": "", "text": "%3Cp%3EYou%20see,%20the%20empty%20curly%20braces%20%7B%7D%20is%20a%20shortcut%20for%20Hash.new.%20The%20new%20method%20is%20used%20to%20make%20objects%0Aof%20a%20certain%20class.%20Think%20“class”%20as%20in%20“working%20class”%20—%20a%20specific%20group%20of%20objects%20which%0Aare%20similar,%20have%20the%20same%20jobs,%20the%20same%20shirts.%0AWhat%20use%20is%20a%20class%20?%3C/p%3E%0A%0A%3Ch3%3EBlurbalizer%3Csup%3ETM%3C/sup%3E%3C/h3%3E%0A%0A%3Cp%3EYou%20just%20had%20a%20brilliant%20idea%20for%20a%20new%20app.%20It%20is%20going%20to%20be%20%3Cstrong%3Ethe%3C/strong%3E%20next%20instant%0Amessaging%20platform.%20You%20want%20an%20app%20where%20people%20can%20send%20each%20other%20short%20messages.%20You%20call%0Athese%20messages%20Blurbs%3Csup%3ETM%3C/sup%3E.%20A%20Blurb%3Csup%3ETM%3C/sup%3E%20has%20a%20maximum%20length%20of%20just%2040%20characters.%20Let’s%20do%20a%20mood%20setting%20too.%3C/p%3E%0A%0A%3C!---The%20Internet%20has%20really%20brought%20back%20stick%20people%20and%20smileys%20out%20of%20bankruptcy.%20__Emote!__--%3E%0A%0A%3Ch3%3EWhere%20to%20start%3C/h3%3E%0A%0A%3Cp%3EWell,%20you%20might%20store%20your%20Blurbs%3Csup%3ETM%3C/sup%3E%20entries%20in%20a%20json%20file,%20right?%0ABut%20how%20would%20you%20keep%20track%20of%20the%20content%20of%20the%20entry%20and%20the%20time%20it%20was%20posted?%0AAnd%20when%20you%20loaded%20the%20file,%20how%20would%20it%20look%20in%20Ruby?%0AWould%20it%20be%20a%20Hash?%20Or%20an%20Array?%20Or%20an%20Array%20of%20Arrays?%20Or%20something%20else?%20%3C/p%3E%0A%0A%3Ch3%3EClass%3C/h3%3E%0A%0A%3Cp%3EI%20really%20think%20you’ll%20want%20to%20use%20a%20class.%20You%20are%20already%20familiar%20with%20many%20classes:%0AHash,%20Array,%20String.%3Cbr%3E%0ALet’s%20make%20a%20new%20class%20(returns%20no%20output):%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Eclass%20Blurb%0Aend%0A%3C/code%3E%3C/pre%3E%0A", "load_code": ""}, + "44": {"lang": "EN", "title": "Me hungry", "chapter": "N", "answer": "%5EMe%20not%20hungry.$", "ok": "Yes", "error": "No%20way%20am%20I%20hungry%20at%2010%20AM!", "text": "%3Cp%3EOkay,%20this%20is%20coming%20along%20wonderfully.%20This%20is%20simple%20stuff%20for%20you,%20but%20keep%20in%20mind%20that%20you%0Adidn’t%20know%20%3Cstrong%3Eany%20Ruby%20whatsoever%3C/strong%3E%20just%20fifteen%20minutes%20ago!%3C/p%3E%0A%0A%3Cp%3ELast%20step.%20Let’s%20tie%20it%20all%20together,%20you%20know?%20Let’s%20make%20it%20chime%20together%20like%20a%20very%20nice%20set%0Aof%20glistening%20chimes%20on%20the%20beach%20in%20the%20maginificent%20sunlight!%3C/p%3E%0A%0A%3Cp%3EWe’ll%20define%20two%20methods%20first%20and%20then%20take%20a%20decision:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Edef%20hungry?(time_of_day_in_hours)%0A%20%20puts%20"Me%20hungry."%0A%20%20true%0Aend%0A%0Adef%20eat_an(what)%0A%20%20puts%20"Me%20eat%20%23%7Bwhat%7D.%5Cn"%0Aend%0A%0Aeat_an%20&%2339;apple&%2339;%20if%20hungry?(14)%0A%0Aeat_an%20&%2339;apple&%2339;%20if%20hungry?(10)%0A%3C/code%3E%3C/pre%3E%0A%0A%3Cp%3ENow%20see%20if%20you%20can%20change%20the%20method%20%3Cstrong%3Ehungry?%3C/strong%3E%20to%20display%20%3Cstrong%3E“Me%20not%20hungry”%3C/strong%3E%20and%20returning%20false%0Awhen%20the%20time%20is%20less%20than%2012.%3C/p%3E%0A", "load_code": ""}, + "45": {"lang": "EN", "title": "Summary #6 Which Means You've Come So Far", "chapter": "Y", "answer": "%5C%7B%5C%7D", "ok": "Ok,%20that's%20an%20empty%20hash", "error": "", "text": "%3Cp%3EYou’re%20a%20level%20six%20Ruby%20cleric.%20I%20mean%20what%20a%20great%20job%20you’ve%20done.%20Let’s%20review:%3C/p%3E%0A%0A%3Ch3%3EData%3C/h3%3E%0A%0A%3Cp%3EYou%20loaded%20some%20data%20of%20the%20internet,%20traversed%20a%20data%20structure%20and%20selected%20values.%3C/p%3E%0A%0A%3Ch3%3EIterating%3C/h3%3E%0A%0A%3Cp%3EYou%20iterated%20all%20elements%20of%20a%20hash%20and%20you%20chained%20some%20more%20methods.%3C/p%3E%0A%0A%3Ch3%3EPretty%20printing%3C/h3%3E%0A%0A%3Cp%3EAnd%20if%20that%20wasn’t%20enough,%20you%20formatted%20and%20printed%20some%20values%20in%20a%20way%20that%20is%20easy%0Ato%20read%20for%20humans.%20In%20fact%20%3Cstrong%3Eyou%20made%20a%20real%20program!%3C/strong%3E%3C/p%3E%0A%0A%3Ch3%3EIF%3C/h3%3E%0A%0A%3Cp%3EYou%20learned%20to%20take%20control%20of%20your%20programs%20with%20%3Cstrong%3Eif%3C/strong%3E%20and%20%3Cstrong%3Eelse%3C/strong%3E%20statements.%3C/p%3E%0A%0A%3Ch2%3ESo%3C/h2%3E%0A%0A%3Cp%3EWhat%20could%20possibly%20be%20next?%20What%20could%20you%20possibly%20have%20to%20learn%20now?%0AHa,%20this%20is%20the%20best%20part.%20You’ve%20come%20such%20a%20long%20way%20that%20we’re%20going%0Ato%20uncover%20classes.%20For%20two%20more%20short%20lessons%20and%20you’re%20done.%3C/p%3E%0A%0A%3Cp%3EEarlier,%20we%20created%20a%20hash%20like%20this:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3EHash.new%0A%3C/code%3E%3C/pre%3E%0A", "load_code": ""}, + "46": {"lang": "EN", "title": "Not a School Class, a Working Class", "chapter": "N", "answer": "", "ok": "", "error": "", "text": "%3Cp%3EYou%20see,%20the%20empty%20curly%20braces%20%7B%7D%20is%20a%20shortcut%20for%20Hash.new.%20The%20new%20method%20is%20used%20to%20make%20objects%0Aof%20a%20certain%20class.%20Think%20“class”%20as%20in%20“working%20class”%20—%20a%20specific%20group%20of%20objects%20which%0Aare%20similar,%20have%20the%20same%20jobs,%20the%20same%20shirts.%0AWhat%20use%20is%20a%20class?%3C/p%3E%0A%0A%3Ch3%3EBlurbalizer%3Csup%3ETM%3C/sup%3E%3C/h3%3E%0A%0A%3Cp%3EYou%20just%20had%20a%20brilliant%20idea%20for%20a%20new%20app.%20It%20is%20going%20to%20be%20%3Cstrong%3Ethe%3C/strong%3E%20next%20instant%0Amessaging%20platform.%20You%20want%20an%20app%20where%20people%20can%20send%20each%20other%20short%20messages.%20You%20call%0Athese%20messages%20Blurbs%3Csup%3ETM%3C/sup%3E.%20A%20Blurb%3Csup%3ETM%3C/sup%3E%20has%20a%20maximum%20length%20of%20just%2040%20characters.%20Let’s%20do%20a%20mood%20setting%20too.%3C/p%3E%0A%0A%3C!---The%20Internet%20has%20really%20brought%20back%20stick%20people%20and%20smileys%20out%20of%20bankruptcy.%20__Emote!__--%3E%0A%0A%3Ch3%3EWhere%20to%20start%3C/h3%3E%0A%0A%3Cp%3EWell,%20you%20might%20store%20your%20Blurbs%3Csup%3ETM%3C/sup%3E%20entries%20in%20a%20json%20file,%20right?%0ABut%20how%20would%20you%20keep%20track%20of%20the%20content%20of%20the%20entry%20and%20the%20time%20it%20was%20posted?%0AAnd%20when%20you%20loaded%20the%20file,%20how%20would%20it%20look%20in%20Ruby?%0AWould%20it%20be%20a%20Hash?%20Or%20an%20Array?%20Or%20an%20Array%20of%20Arrays?%20Or%20something%20else?%3C/p%3E%0A%0A%3Ch3%3EClass%3C/h3%3E%0A%0A%3Cp%3EI%20really%20think%20you’ll%20want%20to%20use%20a%20class.%20You%20are%20already%20familiar%20with%20many%20classes:%0AHash,%20Array,%20String.%0ALet’s%20make%20a%20new%20class%20(returns%20no%20output):%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Eclass%20Blurb%0Aend%0A%3C/code%3E%3C/pre%3E%0A", "load_code": ""}, "47": {"lang": "EN", "title": "The Stuff Apps are Made of", "chapter": "N", "answer": "", "ok": "", "error": "", "text": "%3Cp%3EYou’ve%20opened%20up%20a%20new%20Blurb%3Csup%3ETM%3C/sup%3E%20class.%20What%20is%20your%20blog%20entry%20made%20of?%0AThe%20content,%20sure.%20Also,%20a%20time%20when%20the%20Blurb%3Csup%3ETM%3C/sup%3E%20was%20posted.%20And%20a%20mood.%3C/p%3E%0A%0A%3Cp%3EOkay,%20so%20you’ve%20got%20the%20first%20line%20of%20the%20class,%20here’s%20the%20rest:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Eclass%20Blurb%0A%20%20attr_accessor%20:content,%20:time,%20:mood%0Aend%0A%3C/code%3E%3C/pre%3E%0A%0A%3Cp%3EClass%20names%20always%20begin%20with%20a%20capital%20letter.%3C/p%3E%0A%0A%3Cp%3E(Still%20no%20output)%3C/p%3E%0A", "load_code": ""}, "48": {"lang": "EN", "title": "Accessors Are the Dangling Limbs", "chapter": "N", "answer": "Blurb:", "ok": "My%20first%20Blurb", "error": "", "text": "%3Cp%3EHey,%20good%20class,%20man.%20You’ve%20got%20a%20new%20Blurb%3Csup%3ETM%3C/sup%3E%20class.%3C/p%3E%0A%0A%3Cp%3EIn%20the%20class%20definition,%20you%20used%20a%20method%20called%20attr_accessor.%0AThere%20are%20many%20%3Cstrong%3Eattr%3C/strong%3Eibute%20methods%20like%20this%20which%20add%20little%20settings%20to%20classes.%0AThese%20attributes%20are%20just%20variables%20attached%20to%20a%20class.%3C/p%3E%0A%0A%3Cp%3EThink%20of%20it%20this%20way.%20A%20class%20is%20like%20a%20person.%20That%20star-shaped%20human%20thing%20out%20there.%0AAnd%20the%20attributes%20are%20the%20dangling%20limbs,%20the%20different%20parts%20that%20make%20up%20a%20body%20and%0Aother%20people%20can%20shake%20hands%20with.%3C/p%3E%0A%0A%3Ch3%3ENow%3C/h3%3E%0A%0A%3Cp%3ETo%20create%20a%20Blurb%3Csup%3ETM%3C/sup%3E%20and%20set%20the%20content:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Eblurb1%20=%20Blurb.new%0Aputs%20blurb1%0Ablurb1.content%20=%20"Today%20Mount%20Hood%20Was%20Stolen!"%0A%3C/code%3E%3C/pre%3E%0A", "load_code": "class%20Blurb;attr_accessor%20:content,:time,:mood;end"}, "49": {"lang": "EN", "title": "An Object, That Neat Little Package", "chapter": "N", "answer": "Blurb:", "ok": "Blurb%20updated", "error": "", "text": "%3Cp%3EGo%20ahead%20and%20set%20the%20Blurb%3Csup%3ETM%3C/sup%3E%20time%20and%20mood:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Eblurb1.time%20=%20Time.now%0Ablurb1.mood%20=%20:sick%0A%0Aputs%20blurb1%0A%3C/code%3E%3C/pre%3E%0A", "load_code": "prev;blurb1=Blurb.new;blurb1.content=%22Today%20Mount%20Hood%20Was%20Stolen!%22"}, @@ -52,7 +52,7 @@ "51": {"lang": "EN", "title": "You've Taught Your App to Reject Worthless Things", "chapter": "N", "answer": "Blurb:", "ok": "Blurb%20added", "error": "", "text": "%3Cp%3EDid%20you%20see%20how%20inside%20the%20class%20we%20used%20the%20at-symbols%20(@time).%3C/p%3E%0A%0A%3Cp%3E%3Cstrong%3EOutside%3C/strong%3E%20the%20class,%20we%20use%20accessors:%3C/p%3E%0A%0A%3Cblockquote%3E%0A%3Cp%3E%3Cstrong%3Eblurb.time%20=%20Time.now%3C/strong%3E%3C/p%3E%0A%3C/blockquote%3E%0A%0A%3Cp%3Ebut%20%3Cstrong%3Einside%3C/strong%3E%20we%20use%20the%20%3Cstrong%3Eobject’s%20variables%3C/strong%3E:%3C/p%3E%0A%0A%3Cblockquote%3E%0A%3Cp%3E%3Cstrong%3E@time%20=%20Time.now%3C/strong%3E%3C/p%3E%0A%3C/blockquote%3E%0A%0A%3Cp%3EThey’re%20the%20exact%20same%20thing,%20but%20expressed%20in%20two%20different%20places%20of%20your%20program.%3C/p%3E%0A%0A%3Ch3%3ECreate%20another%20Blurb%3Csup%3ETM%3C/sup%3E%3C/h3%3E%0A%0A%3Cp%3EWhen%20a%20new%20Blurb%3Csup%3ETM%3C/sup%3E%20is%20created,%20the%20initialize%20method%20is%20used%20to%20check%20for%20any%0Aarguments%20to%20new.%3C/p%3E%0A%0A%3Cp%3EUh,%20we%20need%20two%20arguments:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3EBlurb2%20=%20Blurb.new%20:confused,%20"I%20can%20not%20believe%20Mt.%20Hood%20was%20stolen!"%0A%3C/code%3E%3C/pre%3E%0A", "load_code": "class%20Blurb;attr_accessor%20:content,:time,:mood;def%20initialize(mood,%20content=%22%22);@time=Time.now;@content=content[0..39];@mood=mood;end;end;blurb1=Blurb.new(:sick,%22Today%20Mount%20Hood%20Was%20Stolen!%22)"}, "52": {"lang": "EN", "title": "A Giraffe Has Not Stolen Summary #7", "chapter": "Y", "answer": "", "ok": "", "error": "", "text": "%3Cp%3EAha,%20you’re%20here.%20And%20all%20in%20one%20piece.%20We’re%20still%20going%20to%20make%20your%20app%20real,%0Abut%20until%20then,%20let’s%20review,%20okay?%3C/p%3E%0A%0A%3Ch3%3EClasses%3C/h3%3E%0A%0A%3Cp%3EEverything%20in%20Ruby%20is%20some%20kind%20of%20object.%20Classes%20explain%20objects,%20how%20a%20certain%20object%20works.%0AFor%20example,%20you%20made%20a%20few%20Blurb%3Csup%3ETM%3C/sup%3E%20objects%20and%20these%20objects%20are%20explained%20in%20the%20Blurb%0Aclass.%0AIn%20other%20words:%20you%20call%20them%20Blurb%20objects.%0AYou%20can%20use%20classes%20to%20(kinda)%20model%20real%20life%20objects.%3C/p%3E%0A%0A%3Ch3%3EAccessors%3C/h3%3E%0A%0A%3Cp%3EAccessors%20are%20variables%20attached%20to%20an%20object%20which%20can%20be%20used%20%3Cstrong%3Eoutside%3C/strong%3E%20the%20object.%0A(blurb2.time%20=%20Time.now)%3C/p%3E%0A%0A%3Ch3%3EObject%20variables%3C/h3%3E%0A%0A%3Cp%3EObject%20variables%20are%20the%20same%20variables%20you’re%20using%20for%20accessors,%20but%20%3Cstrong%3Einside%3C/strong%3E%20the%20object.%0A(@time%20=%20Time.now)%3C/p%3E%0A", "load_code": "prev;blurb2=Blurb.new%20:confused,%20%22I%20can%20not%20believe%20Mt.%20Hood%20was%20stolen!%22"}, "53": {"lang": "EN", "title": "Your Own Turf", "chapter": "N", "answer": "Blurbalizer:", "ok": "My%20app%20created", "error": "", "text": "%3Cp%3EOkay,%20let’s%20wrap%20things%20up,%20kid.%20Here’s%20the%20last%20chapter%20of%20the%20GRIPPING%20epic%20story%20of%20Try%20Ruby!%0ANow%20that%20you’ve%20got%20a%20taste%20of%20how%20it%20all%20works,%20how%20are%20you%20going%20to%20use%20it%20around%20the%20house%0Aand%20in%20your%20grocer’s%20freezer?%0AYou’re%20a%20great%20person%20(one%20of%20my%20favorites),%20but%20you%20need%20guidance.%3C/p%3E%0A%0A%3Ch3%3ELet’s%20finish%20your%20app%3C/h3%3E%0A%0A%3Cp%3EYou%20have%20app%20entries,%20but%20no%20actual%20app.%0AIt%20still%20needs%20a%20title,%20someplace%20to%20store%20all%20Blurbs%3Csup%3ETM%3C/sup%3E%20and%20a%20timeline%20in%20order%20to%20work.%3C/p%3E%0A%0A%3Cp%3EGuess%20what,%20we’re%20going%20to%20use%20another%20class.%20I’ve%20given%20all%20the%20code%20for%20the%20new%20class%20in%20one%20go.%0AJust%20%3Cstrong%3Etake%20your%20time%3C/strong%3E%20to%20study%20it.%3Cbr%3E%0AI’m%20in%20no%20hurry,%20I’ll%20wait%20for%20you%20in%20the%20next%20lesson.%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Eclass%20Blurbalizer%0A%20%20def%20initialize(title)%0A%20%20%20%20@title%20%20=%20title%0A%20%20%20%20@blurbs%20=%20[]%20%23%20A%20fresh%20clean%20array%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20for%20storing%20Blurbs%0A%20%20end%0A%0A%20%20def%20add_a_blurb(mood,%20content)%0A%20%20%20%20%23%20The%20<<%20means%20add%20to%20the%20end%20of%20the%20array%0A%20%20%20%20@blurbs%20<<%20Blurb.new(mood,%20content)%0A%20%20end%0A%0A%20%20def%20show_timeline%0A%20%20%20%20puts%20"Blurbify:%20%23%7B@title%7D%20has%20%23%7B@blurbs.count%7D%20Blurbs"%0A%0A%20%20%20%20@blurbs.sort_by%20%7B%20%7Ct%7C%0A%20%20%20%20%20%20t.time%0A%20%20%20%20%7D.reverse.each%20%7B%20%7Ct%7C%0A%20%20%20%20%20%20puts%20"%23%7Bt.content.ljust(40)%7D%20%23%7Bt.time%7D"%0A%20%20%20%20%7D%0A%20%20end%0Aend%0A%0Amyapp%20=%20Blurbalizer.new%20"The%20Big%20Blurb"%0A%3C/code%3E%3C/pre%3E%0A", "load_code": "class%20Blurb;attr_accessor%20:content,:time,:mood;def%20initialize(mood,%20content=%22%22);@time=Time.now;@content=content[0..39];@mood=mood;end;end"}, - "54": {"lang": "EN", "title": "What's that Blurb all about?", "chapter": "N", "answer": "Today", "ok": "Bring%20on%20the%20blurbs", "error": "", "text": "%3Cp%3EThere%20you%20are.%20Did%20you%20figure%20out%20what%20all%20that%20code%20in%20the%20Blurbalizer%3Csup%3ETM%3C/sup%3E%20class%20does%20?%3C/p%3E%0A%0A%3Cblockquote%3E%0A%3Cp%3EIn%20the%20Blurbalizer%3Csup%3ETM%3C/sup%3E%20class%20are%20two%20%3Cstrong%3Emethods%3C/strong%3E%20(add_a_blurb%20and%20show_timeline).%0AYou%20can%20use%20a%20method%20outside%20the%20class,%20just%20like%20we%20did%20with%20accessors.%3C/p%3E%0A%3C/blockquote%3E%0A%0A%3Cp%3ETime%20to%20start%20using%20Blurbalizer%3Csup%3ETM%3C/sup%3E.%20I’ve%20already%20loaded%20some%20Blurbs%3Csup%3ETM%3C/sup%3E%20for%20you,%0Abut%20feel%20free%20to%20add%20your%20own.%3C/p%3E%0A%0A%3Cp%3EWe’re%20no%20longer%20creating%20Blurbs%3Csup%3ETM%3C/sup%3E%20directly,%20but%20we%20use%20the%20add_a_blurb%20%3Cstrong%3Emethod%3C/strong%3E%20of%20the%0ABlurbalizer%3Csup%3ETM%3C/sup%3E%20class.%20This%20way%20we%20can%20be%20sure%20all%20our%20Blurbs%3Csup%3ETM%3C/sup%3E%20are%20stored%20in%20the%0Amyapp%20object.%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Emyapp.add_a_blurb%20:moody,%20"Add%20Blurb%20here"%0A%0Amyapp.show_timeline%0A%3C/code%3E%3C/pre%3E%0A", "load_code": "prev;class%20Blurbalizer;attr_reader%20:title;def%20initialize(title);@title=title;@blurbs=[];end;def%20add_a_blurb(mood,%20content);@blurbs%20%3C%3C%20Blurb.new(mood,%20content);@blurbs.each%20%7B%7Ct%7C%20t.time%20-=%2073%7D;end;def%20show_timeline;puts%20%22Blurbalizer:%20%23%7B@title%7D%20has%20%23%7B@blurbs.count%7D%20Blurbs%5Cn%22;@blurbs.sort_by%20%7B%20%7Ct%7C%20t.time%7D.reverse.each%20%7B%20%7Ct%7C%20puts%20%22%23%7Bt.content.ljust(40)%7D%20%23%7Bt.time%7D%22%7D;end;end;myapp%20=%20Blurbalizer.new%20%22The%20Big%20Blurb%22;myapp.add_a_blurb%20:sick,%22Today%20Mount%20Hood%20Was%20Stolen!%22;myapp.add_a_blurb%20:confused,%22I%20can%20not%20believe%20Mt.%20Hood%20was%20stolen!%22;myapp.add_a_blurb%20:dazed,%22I%20am%20speechless!%22;myapp.add_a_blurb%20:mad,%22It%20was%20stolen%20by%20a%20giraffe%20!!%22;myapp.add_a_blurb%20:sad,%22I%20Left%20my%20Hoodie%20on%20the%20Mountain!%22;myapp.add_a_blurb%20:mad,%22I%20am%20never%20going%20back%20to%20that%20mountain.%22"}, - "55": {"lang": "EN", "title": "It's All About Combining", "chapter": "N", "answer": ":-", "ok": "Moody%20!", "error": "", "text": "%3Cp%3ESome%20beautiful%20things%20can%20be%20done%20with%20the%20simple%20parts%20of%20Ruby,%20especially%20when%20you%20combine%20them%0Atogether%20into%20new%20things.%3Cbr%3E%0AHere%20we’ve%20got%20an%20app%20made%20of%20a%20class%20containing%20another%20class.%20And,%20actually,%20Ruby%20really%20does%20good%0Awith%20this%20kind%20of%20creature.%20It%20is%20called%20object%20oriented%20programming.%3C/p%3E%0A%0A%3Cp%3EWe%20have%20arrived%20at%20the%20%3Cstrong%3Elast%20programming%20excercise%3C/strong%3E%20of%20TryRuby.%20If%20you%20want,%20you%20can%20add%20some%0Amore%20features%20to%20Blurbalizer%3Csup%3ETM%3C/sup%3E.%3C/p%3E%0A%0A%3Cp%3EMaybe%20you%20want%20to%20print%20the%20mood%20as%20a%20smiley%20in%20the%20%3Cstrong%3Eshow_timeline%3C/strong%3E%20method.%20You%20could%20add%0Aa%20%3Cem%3Emoodify%3C/em%3E%20method%20to%20the%20Blurb%3Csup%3ETM%3C/sup%3E%20class%20and%20then%20use%20that%20method%20in%20the%20%3Cem%3Eshow_timeline%3C/em%3E%20method:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Eclass%20Blurb%0A%20%20attr_accessor%20:content,%20:time,%20:mood%0A%0A%20%20def%20initialize(mood,%20content="")%0A%20%20%20%20@time%20%20%20%20=%20Time.now%0A%20%20%20%20@content%20=%20content[0..39]%0A%20%20%20%20@mood%20%20%20%20=%20mood%0A%20%20end%0A%0A%20%20def%20moodify%0A%20%20%20%20if%20%20%20%20@mood%20==%20:sad%0A%20%20%20%20%20%20return%20":-("%0A%20%20%20%20elsif%20@mood%20==%20:happy%0A%20%20%20%20%20%20return%20":-)"%0A%20%20%20%20%23%20Add%20other%20moods%20here%0A%20%20%20%20end%0A%0A%20%20%20%20%23%20The%20default%20mood%0A%20%20%20%20":-%7C"%0A%20%20end%0Aend%0A%0Aclass%20Blurbalizer%0A%20%20def%20initialize(title)%0A%20%20%20%20@title%20%20=%20title%0A%20%20%20%20@blurbs%20=%20[]%0A%20%20end%0A%0A%20%20def%20add_a_blurb(mood,%20content)%0A%20%20%20%20@blurbs%20<<%20Blurb.new(mood,%20content)%0A%20%20end%0A%0A%20%20def%20show_timeline%0A%20%20%20%20puts%20"Blurbalizer:%20%23%7B@title%7D%20has%20%23%7B@blurbs.count%7D%20Blurbs"%0A%0A%20%20%20%20@blurbs.sort_by%20%7B%20%7Ct%7C%0A%20%20%20%20%20%20t.time%0A%20%20%20%20%7D.reverse.each%20%7B%20%7Ct%7C%0A%20%20%20%20%20%20puts%20"%23%7Bt.content.ljust(40)%7D%20%23%7Bt.time%7D"%0A%20%20%20%20%7D%0A%20%20end%0Aend%0A%0Amyapp.show_timeline%0A%3C/code%3E%3C/pre%3E%0A", "load_code": "prev"}, + "54": {"lang": "EN", "title": "What's that Blurb all about?", "chapter": "N", "answer": "Today", "ok": "Bring%20on%20the%20blurbs", "error": "", "text": "%3Cp%3EThere%20you%20are.%20Did%20you%20figure%20out%20what%20all%20that%20code%20in%20the%20Blurbalizer%3Csup%3ETM%3C/sup%3E%20class%20does?%3C/p%3E%0A%0A%3Cblockquote%3E%0A%3Cp%3EIn%20the%20Blurbalizer%3Csup%3ETM%3C/sup%3E%20class%20are%20two%20%3Cstrong%3Emethods%3C/strong%3E%20(add_a_blurb%20and%20show_timeline).%0AYou%20can%20use%20a%20method%20outside%20the%20class,%20just%20like%20we%20did%20with%20accessors.%3C/p%3E%0A%3C/blockquote%3E%0A%0A%3Cp%3ETime%20to%20start%20using%20Blurbalizer%3Csup%3ETM%3C/sup%3E.%20I’ve%20already%20loaded%20some%20Blurbs%3Csup%3ETM%3C/sup%3E%20for%20you,%0Abut%20feel%20free%20to%20add%20your%20own.%3C/p%3E%0A%0A%3Cp%3EWe’re%20no%20longer%20creating%20Blurbs%3Csup%3ETM%3C/sup%3E%20directly,%20but%20we%20use%20the%20add_a_blurb%20%3Cstrong%3Emethod%3C/strong%3E%20of%20the%0ABlurbalizer%3Csup%3ETM%3C/sup%3E%20class.%20This%20way%20we%20can%20be%20sure%20all%20our%20Blurbs%3Csup%3ETM%3C/sup%3E%20are%20stored%20in%20the%0Amyapp%20object.%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Emyapp.add_a_blurb%20:moody,%20"Add%20Blurb%20here"%0A%0Amyapp.show_timeline%0A%3C/code%3E%3C/pre%3E%0A", "load_code": "prev;class%20Blurbalizer;attr_reader%20:title;def%20initialize(title);@title=title;@blurbs=[];end;def%20add_a_blurb(mood,%20content);@blurbs%20%3C%3C%20Blurb.new(mood,%20content);@blurbs.each%20%7B%7Ct%7C%20t.time%20-=%2073%7D;end;def%20show_timeline;puts%20%22Blurbalizer:%20%23%7B@title%7D%20has%20%23%7B@blurbs.count%7D%20Blurbs%5Cn%22;@blurbs.sort_by%20%7B%20%7Ct%7C%20t.time%7D.reverse.each%20%7B%20%7Ct%7C%20puts%20%22%23%7Bt.content.ljust(40)%7D%20%23%7Bt.time%7D%22%7D;end;end;myapp%20=%20Blurbalizer.new%20%22The%20Big%20Blurb%22;myapp.add_a_blurb%20:sick,%22Today%20Mount%20Hood%20Was%20Stolen!%22;myapp.add_a_blurb%20:confused,%22I%20can%20not%20believe%20Mt.%20Hood%20was%20stolen!%22;myapp.add_a_blurb%20:dazed,%22I%20am%20speechless!%22;myapp.add_a_blurb%20:mad,%22It%20was%20stolen%20by%20a%20giraffe%20!!%22;myapp.add_a_blurb%20:sad,%22I%20Left%20my%20Hoodie%20on%20the%20Mountain!%22;myapp.add_a_blurb%20:mad,%22I%20am%20never%20going%20back%20to%20that%20mountain.%22"}, + "55": {"lang": "EN", "title": "It's All About Combining", "chapter": "N", "answer": ":-", "ok": "Moody!", "error": "", "text": "%3Cp%3ESome%20beautiful%20things%20can%20be%20done%20with%20the%20simple%20parts%20of%20Ruby,%20especially%20when%20you%20combine%20them%0Atogether%20into%20new%20things.%0AHere%20we’ve%20got%20an%20app%20made%20of%20a%20class%20containing%20another%20class.%20And,%20actually,%20Ruby%20really%20does%20good%0Awith%20this%20kind%20of%20creature.%20It%20is%20called%20object%20oriented%20programming.%3C/p%3E%0A%0A%3Cp%3EWe%20have%20arrived%20at%20the%20%3Cstrong%3Elast%20programming%20excercise%3C/strong%3E%20of%20TryRuby.%20If%20you%20want,%20you%20can%20add%20some%0Amore%20features%20to%20Blurbalizer%3Csup%3ETM%3C/sup%3E.%3C/p%3E%0A%0A%3Cp%3EMaybe%20you%20want%20to%20print%20the%20mood%20as%20a%20smiley%20in%20the%20%3Cstrong%3Eshow_timeline%3C/strong%3E%20method.%20You%20could%20add%0Aa%20%3Cem%3Emoodify%3C/em%3E%20method%20to%20the%20Blurb%3Csup%3ETM%3C/sup%3E%20class%20and%20then%20use%20that%20method%20in%20the%20%3Cem%3Eshow_timeline%3C/em%3E%20method:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Eclass%20Blurb%0A%20%20attr_accessor%20:content,%20:time,%20:mood%0A%0A%20%20def%20initialize(mood,%20content="")%0A%20%20%20%20@time%20%20%20%20=%20Time.now%0A%20%20%20%20@content%20=%20content[0..39]%0A%20%20%20%20@mood%20%20%20%20=%20mood%0A%20%20end%0A%0A%20%20def%20moodify%0A%20%20%20%20if%20%20%20%20@mood%20==%20:sad%0A%20%20%20%20%20%20return%20":-("%0A%20%20%20%20elsif%20@mood%20==%20:happy%0A%20%20%20%20%20%20return%20":-)"%0A%20%20%20%20%23%20Add%20other%20moods%20here%0A%20%20%20%20end%0A%0A%20%20%20%20%23%20The%20default%20mood%0A%20%20%20%20":-%7C"%0A%20%20end%0Aend%0A%0Aclass%20Blurbalizer%0A%20%20def%20initialize(title)%0A%20%20%20%20@title%20%20=%20title%0A%20%20%20%20@blurbs%20=%20[]%0A%20%20end%0A%0A%20%20def%20add_a_blurb(mood,%20content)%0A%20%20%20%20@blurbs%20<<%20Blurb.new(mood,%20content)%0A%20%20end%0A%0A%20%20def%20show_timeline%0A%20%20%20%20puts%20"Blurbalizer:%20%23%7B@title%7D%20has%20%23%7B@blurbs.count%7D%20Blurbs"%0A%0A%20%20%20%20@blurbs.sort_by%20%7B%20%7Ct%7C%0A%20%20%20%20%20%20t.time%0A%20%20%20%20%7D.reverse.each%20%7B%20%7Ct%7C%0A%20%20%20%20%20%20puts%20"%23%7Bt.content.ljust(40)%7D%20%23%7Bt.time%7D"%0A%20%20%20%20%7D%0A%20%20end%0Aend%0A%0Amyapp.show_timeline%0A%3C/code%3E%3C/pre%3E%0A", "load_code": "prev"}, "56": {"lang": "EN", "title": "Summary #8, The Hey-Relax-You-Did-Good Summary", "chapter": "Y", "answer": "", "ok": "", "error": "", "text": "%3Cp%3EThis%20last%20section%20took%20a%20moment%20to%20wind%20down,%20to%20give%20you%20some%20pointers%20as%20to%20how%20you%20can%20use%20Ruby.%3C/p%3E%0A%0A%3Cp%3EIf%20you%20enjoyed%20yourself,%20you%20can%20continue%20with%20the%20%3Ca%20href=%22/TryRuby/playground%22%3ETryRuby%20Playground%3C/a%3E%0Aor%20download%20and%20install%20Ruby:%0A%3Ca%20href=%22https://www.ruby-lang.org/en/downloads/%22%20target=%22_blank%22%3Eruby-lang.org%3C/a%3E%3C/p%3E%0A%0A%3Cp%3EOnce%20you%20have%20Ruby%20installed,%20you%20can%20create%20a%20file,%20let%20say%20%3Cem%3Emy_first_progam.rb%3C/em%3E,%20with%20a%20text%0Aeditor,%20type%20some%20Ruby%20code%20and%20then%20run%20it%20by%20opening%20a%20command%20prompt%20and%20typing:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3Eruby%20my_first_progam.rb%0A%3C/code%3E%3C/pre%3E%0A%0A%3Cp%3EThere%20are%20many%20(free)%20development%20tools%20available%20that%20combine%20an%20editor,%20file%20browser%20and%20a%0A‘ruby-runner’.%3C/p%3E%0A%0A%3Ch2%3ECelebrate%3C/h2%3E%0A%0A%3Cp%3EYou%20really%20deserve%20a%20double-layer%20cake%20with%20double-double%20frosting%20and%20a%20guy%20playing%20one%20of%20those%20guitars%20that’s%20a%20double%20guitar.%0AI%20mean%20you%20finished,%20you%20really%20did!%20No%20doubt%20about%20it,%20you’re%20a%20%3Cstrong%3Ecertified%20red-blooded%20smartiac!%3C/strong%3E%3C/p%3E%0A%0A%3Ch2%3EMore%20info%3C/h2%3E%0A%0A%3Cp%3EThere%20are%20a%20couple%20of%20articles%20on%20this%20website.%20They%20can%20give%20you%20some%20pointers%20on%20where%20to%0Ago%20from%20here.%3C/p%3E%0A", "load_code": "def%20ruby(f);puts%20%22Go%20to%20www.ruby-lang.org%20to%20download%20Ruby%22;end;class%20K;attr_reader%20:rb;end;my_first_progam=K.new"} } \ No newline at end of file diff --git a/translations/en/try_ruby_170.md b/translations/en/try_ruby_170.md index 549d7c86..17f92ce2 100644 --- a/translations/en/try_ruby_170.md +++ b/translations/en/try_ruby_170.md @@ -7,11 +7,11 @@ ok: Ok error: Almost --- -So we stored our lotto numbers inside variable ticket. How to get 'em out again ? +So we stored our lotto numbers inside variable ticket. How to get 'em out again? We already saw that we can get the highest number with __max__. Similarly you can get the __first__ or the __last__ element of the list. -But what if you want a specific element ? +But what if you want a specific element? ### [ ] Ruby uses the square brackets [ ] to target an element. @@ -25,9 +25,9 @@ Let's get all of our lotto numbers: puts ticket[1] puts ticket[2] -Why do we use [0], [1], [2] ? +Why do we use [0], [1], [2]? -And not [1], [2] and [3] ? Is that some kind of Japanese Zen thing ? +And not [1], [2] and [3]? Is that some kind of Japanese Zen thing? No, we computer people just like to begin counting from zero. It's not just a Ruby thing, this _zero based indexing_ is used in most programming languages. diff --git a/translations/en/try_ruby_180.md b/translations/en/try_ruby_180.md index 4e4d6a61..fd801729 100644 --- a/translations/en/try_ruby_180.md +++ b/translations/en/try_ruby_180.md @@ -4,8 +4,8 @@ title: Summary #2 is Upon Us answer: \w+ class: stretcher chapmark load: poem = "My toast has flown from my hand\nAnd my toast has gone to the moon.\nBut when I saw it on television,\nPlanting our flag on Halley's comet,\nMore still did I want to eat it.\n" -ok: Does it rhyme ? -error: +ok: Does it rhyme? +error: --- Now, look how your second minute went: diff --git a/translations/en/try_ruby_230.md b/translations/en/try_ruby_230.md index 750633ab..94d4128a 100644 --- a/translations/en/try_ruby_230.md +++ b/translations/en/try_ruby_230.md @@ -4,8 +4,8 @@ title: Of All the Summaries, #3 is Here Now answer: \{\} class: stretcher chapmark load: prev -ok: You've made an empty hash ! -error: +ok: You've made an empty hash! +error: --- ### Exclamations @@ -24,7 +24,7 @@ methods is So I guess the conclusion is that you can do whatever you like with parenthesis as long as your > code reads nicely. @@ -35,4 +35,4 @@ version without parenthesis is a bit easier to read. And it saves you valuable t So if _to_ is a method and _be_ is an argument we now know the answer to this age old question. It is really just a matter of preference whether you want _to be_ or _to(be)_. -Are you in the mood for more Shakespeare ? Read on. +Are you in the mood for more Shakespeare? Read on. diff --git a/translations/en/try_ruby_330.md b/translations/en/try_ruby_330.md index 1b1638ab..cfbb4b34 100644 --- a/translations/en/try_ruby_330.md +++ b/translations/en/try_ruby_330.md @@ -2,8 +2,8 @@ lang: EN title: The Taming of the Shrew answer: ^tame -ok: Good good ! -error: +ok: Good good! +error: --- You totally know how to use Ruby now. I mean you've got down the essentials. @@ -27,7 +27,7 @@ read and understand that code later. Instead you should cut up your code in different methods and give each method an easy to understand English name. You will thank yourself later. -So how do we define a method ? Like this: +So how do we define a method? Like this: def tame( number_of_shrews ) end diff --git a/translations/en/try_ruby_360.md b/translations/en/try_ruby_360.md index a2b3d9d5..b125e02d 100644 --- a/translations/en/try_ruby_360.md +++ b/translations/en/try_ruby_360.md @@ -3,7 +3,7 @@ lang: EN title: Give and take answer: \d+ ok: Right on. Bravo. -error: +error: --- Most methods do not only want some parameters as input, but will also __give something back__. @@ -15,7 +15,7 @@ I have changed our method a bit so it will return a value to you. Try it: } return number_of_shrews end - + puts tame(3) ### Return @@ -26,4 +26,4 @@ Ruby will automagically return the last value that was used inside the method. So we can change the last line to just: __number\_of\_shrews__. But since method __.times__ also returns the _number\_of\_shrews_ we can -remove the entire last line. So in fact our original method already did what we wanted all along ! +remove the entire last line. So in fact our original method already did what we wanted all along! diff --git a/translations/en/try_ruby_370.md b/translations/en/try_ruby_370.md index 8098d3d5..e0565b7d 100644 --- a/translations/en/try_ruby_370.md +++ b/translations/en/try_ruby_370.md @@ -1,10 +1,10 @@ --- lang: EN title: Hello, Who's There? And Summary #5 Waves Its Hat! -answer: +answer: class: stretcher chapmark -ok: -error: +ok: +error: --- Well done, well done, well done, well done! @@ -24,4 +24,4 @@ Methods can have parameters. Methods (almost) always return a value. ## Now -To (be) or not to (be) is not a question to you anymore. Are you ready for some more Shakespeare ? +To (be) or not to (be) is not a question to you anymore. Are you ready for some more Shakespeare? diff --git a/translations/en/try_ruby_40.md b/translations/en/try_ruby_40.md index 106ca039..ddb5fbdf 100644 --- a/translations/en/try_ruby_40.md +++ b/translations/en/try_ruby_40.md @@ -3,11 +3,11 @@ lang: EN title: Putting it differently answer: ^[0-9\.,-]{1,}$ ok: Well put -error: +error: --- Did you notice that if you typed more than one formula you only saw the answer for the last one. -What is going on ? +What is going on? > To make this website easier to use I have told Ruby to copy the result of your program to the > output screen at the top. So when you type a formula you get to see the results. @@ -15,7 +15,7 @@ What is going on ? So when you entered 2 or more formula's, Ruby only showed the result of the last formula. -Of course you have the power to control the screen ! Just type __puts__ before each formula +Of course you have the power to control the screen! Just type __puts__ before each formula (with a space in between). Puts means: *'put something on the screen'*. Try this: diff --git a/translations/en/try_ruby_410.md b/translations/en/try_ruby_410.md index 1ec0b868..f7f982f9 100644 --- a/translations/en/try_ruby_410.md +++ b/translations/en/try_ruby_410.md @@ -37,4 +37,4 @@ length of 30 characters so the years align nicely. See if you can change the ouput of the program so that it shows the plays like this: __1600 -> As You Like It__ -__All's Well That Ends Well ?__ Hey we're not done yet, but the end is in sight ! +__All's Well That Ends Well?__ Hey we're not done yet, but the end is in sight! diff --git a/translations/en/try_ruby_440.md b/translations/en/try_ruby_440.md index 7c3c7d0e..c5bea888 100644 --- a/translations/en/try_ruby_440.md +++ b/translations/en/try_ruby_440.md @@ -3,7 +3,7 @@ lang: EN title: Me hungry answer: ^Me not hungry.$ ok: Yes -error: No way am I hungry at 10 AM ! +error: No way am I hungry at 10 AM! --- Okay, this is coming along wonderfully. This is simple stuff for you, but keep in mind that you @@ -18,13 +18,13 @@ We'll define two methods first and then take a decision: puts "Me hungry." true end - + def eat_an(what) puts "Me eat #{what}.\n" end - + eat_an 'apple' if hungry?(14) - + eat_an 'apple' if hungry?(10) Now see if you can change the method __hungry?__ to display __"Me not hungry"__ and returning false diff --git a/translations/en/try_ruby_450.md b/translations/en/try_ruby_450.md index 0b263950..4f00f2dc 100644 --- a/translations/en/try_ruby_450.md +++ b/translations/en/try_ruby_450.md @@ -4,7 +4,7 @@ title: Summary #6 Which Means You've Come So Far answer: \{\} class: stretcher chapmark ok: Ok, that's an empty hash -error: +error: --- You're a level six Ruby cleric. I mean what a great job you've done. Let's review: @@ -18,7 +18,7 @@ You iterated all elements of a hash and you chained some more methods. ### Pretty printing And if that wasn't enough, you formatted and printed some values in a way that is easy -to read for humans. In fact __you made a real program !__ +to read for humans. In fact __you made a real program!__ ### IF You learned to take control of your programs with __if__ and __else__ statements. @@ -28,6 +28,6 @@ What could possibly be next? What could you possibly have to learn now? Ha, this is the best part. You've come such a long way that we're going to uncover classes. For two more short lessons and you're done. -Earlier, we created a hash like this: +Earlier, we created a hash like this: Hash.new diff --git a/translations/en/try_ruby_460.md b/translations/en/try_ruby_460.md index fcb68e5b..2f98a959 100644 --- a/translations/en/try_ruby_460.md +++ b/translations/en/try_ruby_460.md @@ -1,15 +1,15 @@ --- lang: EN title: Not a School Class, a Working Class -answer: -ok: -error: +answer: +ok: +error: --- You see, the empty curly braces {} is a shortcut for Hash.new. The new method is used to make objects of a certain class. Think "class" as in "working class" — a specific group of objects which are similar, have the same jobs, the same shirts. -What use is a class ? +What use is a class? ### BlurbalizerTM You just had a brilliant idea for a new app. It is going to be __the__ next instant @@ -22,11 +22,11 @@ these messages BlurbsTM. A BlurbTM has a maximum length of Well, you might store your BlurbsTM entries in a json file, right? But how would you keep track of the content of the entry and the time it was posted? And when you loaded the file, how would it look in Ruby? -Would it be a Hash? Or an Array? Or an Array of Arrays? Or something else? +Would it be a Hash? Or an Array? Or an Array of Arrays? Or something else? ### Class I really think you'll want to use a class. You are already familiar with many classes: -Hash, Array, String. +Hash, Array, String. Let's make a new class (returns no output): class Blurb diff --git a/translations/en/try_ruby_540.md b/translations/en/try_ruby_540.md index 7b756365..620e5e55 100644 --- a/translations/en/try_ruby_540.md +++ b/translations/en/try_ruby_540.md @@ -3,11 +3,11 @@ lang: EN title: What's that Blurb all about? answer: Today ok: Bring on the blurbs -error: +error: load: prev;class Blurbalizer;attr_reader :title;def initialize(title);@title=title;@blurbs=[];end;def add_a_blurb(mood, content);@blurbs << Blurb.new(mood, content);@blurbs.each {|t| t.time -= 73};end;def show_timeline;puts "Blurbalizer: #{@title} has #{@blurbs.count} Blurbs\n";@blurbs.sort_by { |t| t.time}.reverse.each { |t| puts "#{t.content.ljust(40)} #{t.time}"};end;end;myapp = Blurbalizer.new "The Big Blurb";myapp.add_a_blurb :sick,"Today Mount Hood Was Stolen!";myapp.add_a_blurb :confused,"I can not believe Mt. Hood was stolen!";myapp.add_a_blurb :dazed,"I am speechless!";myapp.add_a_blurb :mad,"It was stolen by a giraffe !!";myapp.add_a_blurb :sad,"I Left my Hoodie on the Mountain!";myapp.add_a_blurb :mad,"I am never going back to that mountain." --- -There you are. Did you figure out what all that code in the BlurbalizerTM class does ? +There you are. Did you figure out what all that code in the BlurbalizerTM class does? > In the BlurbalizerTM class are two __methods__ (add\_a\_blurb and show\_timeline). > You can use a method outside the class, just like we did with accessors. @@ -20,5 +20,5 @@ BlurbalizerTM class. This way we can be sure all our BlurbsTMTM class and then use that method in t class Blurb attr_accessor :content, :time, :mood - + def initialize(mood, content="") @time = Time.now @content = content[0..39] @mood = mood end - + def moodify if @mood == :sad return ":-(" @@ -39,20 +39,20 @@ a _moodify_ method to the BlurbTM class and then use that method in t ":-|" end end - + class Blurbalizer def initialize(title) @title = title @blurbs = [] end - + def add_a_blurb(mood, content) @blurbs << Blurb.new(mood, content) end - + def show_timeline puts "Blurbalizer: #{@title} has #{@blurbs.count} Blurbs" - + @blurbs.sort_by { |t| t.time }.reverse.each { |t| @@ -60,5 +60,5 @@ a _moodify_ method to the BlurbTM class and then use that method in t } end end - + myapp.show_timeline