99 "8" : {"lang" : " EN" , "title" : " On Repeat" , "chapter" : " N" , "answer" : " (%5Cw+)" , "ok" : " Nice%20to%20meet%20you.Nice%20to%20meet%20you.Nice%20to%20meet%20you." , "error" : " " , "text" : " %3Cp%3ENow,%20you’re%20probably%20wondering%20what%20any%20of%20this%20is%20good%20for.%3C/p%3E%0A%0A%3Cp%3EWell,%20I’m%20sure%20you’ve%20been%20to%20a%20website%20that%20screamed,%20%3Cstrong%3EHey,%20your%20password%20is%20too%20short!%3C/strong%3E%3C/p%3E%0A%0A%3Cp%3ESee,%20some%20programs%20use%20that%20simple%20%3Cstrong%3E.length%3C/strong%3E%20code.%3C/p%3E%0A%0A%3Cp%3EWatch%20this.%20Let’s%20multiply%20your%20name%20by%205.%20%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3E"Jimmy"%20*%205%0A%3C/code%3E%3C/pre%3E%0A" , "load_code" : " " },
1010 "9": {"lang": "EN", "title": "Hey, Summary #1 Already", "chapter": "Y", "answer": "%5ENoMethodError(.*)$", "ok": "Nope,%20it%20is%20not%20possible%20to%20reverse%20a%20number.%20Click%20'next'", "error": "", "text": "%3Cp%3ELet’s%20look%20at%20what%20you’ve%20learned%20in%20the%20first%20minute.%3C/p%3E%0A%0A%3Ch3%3EThe%20editor%3C/h3%3E%0A%0A%3Cp%3ETyping%20code%20into%20the%20editor%20and%20clicking%20on%20run%20gives%20you%20an%20answer%20in%20the%20ouput%20window.%0A(Almost)%20all%20code%20gives%20an%20answer.%3C/p%3E%0A%0A%3Ch3%3ENumbers%20and%20strings%3C/h3%3E%0A%0A%3Cp%3ENumbers%20and%20strings%20are%20Ruby’s%20math%20and%20text%20objects.%3C/p%3E%0A%0A%3Ch3%3EMethods%3C/h3%3E%0A%0A%3Cp%3EYou’ve%20used%20English-language%20methods%20like%20reverse%20and%20length.%20And%20symbolic%20methods%20like%20the%0Amultiplication%20method:%20*%3Cbr%3E%0A%3Cstrong%3EMethods%20mean%20action!%3C/strong%3E%3C/p%3E%0A%0A%3Cp%3EThis%20is%20the%20essence%20of%20your%20learning.%20Taking%20simple%20things,%20toying%20with%20them%20and%20turning%20them%20into%0Anew%20things.%20Feeling%20comfortable%20yet?%20I%20promise%20you%20are.%3C/p%3E%0A%0A%3Ch2%3EOkay,%3C/h2%3E%0A%0A%3Cp%3Elet’s%20do%20something%20uncomfortable.%20Try%20reversing%20a%20number:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3E40.reverse%0A%3C/code%3E%3C/pre%3E%0A", "load_code": ""},
1111 "10" : {"lang" : " EN" , "title" : " Stop, You're Barking Mad!" , "chapter" : " N" , "answer" : " %5E%5Cd%7B1,%7D$" , "ok" : " Only%20strings%20can%20be%20reversed" , "error" : " " , "text" : " %3Cp%3EYou%20can’t%20reverse%20the%20number%20forty.%20I%20guess%20you%20can%20hold%20your%20monitor%20up%20to%20the%20mirror,%20but%20reversing%20a%20number%20just%20doesn’t%20make%20sense.%3C/p%3E%0A%0A%3Cp%3ERuby%20has%20tossed%20an%20error%20message.%20Ruby%20is%20telling%20you%20there%20is%20no%20method%20reverse%20for%20numbers.%3C/p%3E%0A%0A%3Cp%3EMaybe%20if%20you%20turn%20the%20number%20into%20a%20string%20first:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3E40.to_s.reverse%0A%3C/code%3E%3C/pre%3E%0A" , "load_code" : " " },
12- "11": {"lang": "EN", "title": "Apples are Different From Oranges", "chapter": "N", "answer": "%5C[%5C]", "ok": "Great,%20that's%20an%20empty%20list", "error": "", "text": "%3Cp%3EAnd%20numbers%20are%20different%20from%20strings.%3C/p%3E%0A%0A%3Cp%3EWhile%20you%20can%20use%20methods%20on%20any%20object%20in%20Ruby,%20some%20methods%20only%20work%20on%20certain%20types%20of%20things.%0ABut%20you%20can%20always%20convert%20between%20different%20types%20using%20Ruby’s%20“to”%20methods.%3C/p%3E%0A%0A%3Cul%3E%0A%3Cli%3E%3Cstrong%3Eto_s%3C/strong%3E%20converts%20things%20to%20%3Cstrong%3Es%3C/strong%3Etrings%3C/li%3E%0A%3Cli%3E%3Cstrong%3Eto_i%3C/strong%3E%20converts%20things%20to%20%3Cstrong%3Ei%3C/strong%3Entegers%20(numbers)%3C/li%3E%0A%3Cli%3E%3Cstrong%3Eto_a%3C/strong%3E%20converts%20things%20to%20%3Cstrong%3Ea%3C/strong%3Errays%3C/li%3E%0A%3C/ul%3E%0A%0A%3Cp%3E%3Cstrong%3EWhat%20are%20arrays?!%3C/strong%3E%3C/p%3E%0A%0A%3Cp%3EThey%20are%20lists.%20Type%20in%20a%20pair%20of%20brackets:%20%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3E[]%0A%3C/code%3E%3C/pre%3E%0A", "load_code": ""},
12+ "11": {"lang": "EN", "title": "Apples are Different From Oranges", "chapter": "N", "answer": "%5C[%5C]", "ok": "Great,%20that's%20an%20empty%20list", "error": "", "text": "%3Cp%3EAnd%20numbers%20are%20different%20from%20strings.%3C/p%3E%0A%0A%3Cp%3EWhile%20you%20can%20use%20methods%20on%20any%20object%20in%20Ruby,%20some%20methods%20only%20work%20on%20certain%20types%20of%20things.%0ABut%20you%20can%20always%20convert%20between%20different%20types%20using%20Ruby’s%20“to”%20methods.%3C/p%3E%0A%0A%3Cul%3E%0A%3Cli%3E%3Cstrong%3Eto_s%3C/strong%3E%20converts%20things%20to%20%3Cstrong%3Es%3C/strong%3Etrings%3C/li%3E%0A%3Cli%3E%3Cstrong%3Eto_i%3C/strong%3E%20converts%20things%20to%20%3Cstrong%3Ei%3C/strong%3Entegers%20(numbers)%3C/li%3E%0A%3Cli%3E%3Cstrong%3Eto_a%3C/strong%3E%20converts%20things%20to%20%3Cstrong%3Ea%3C/strong%3Errays%3C/li%3E%0A%3C/ul%3E%0A%0A%3Cp%3E%3Cstrong%3EWhat%20are%20arrays?!%3C/strong%3E%3C/p%3E%0A%0A%3Cp%3EThey%20are%20lists.%20Type%20in%20a%20pair%20of%20brackets:%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3E[]%0A%3C/code%3E%3C/pre%3E%0A", "load_code": ""},
1313 "12" : {"lang" : " EN" , "title" : " Standing in Line" , "chapter" : " N" , "answer" : " %5E%5C[(%5Cd+)(,%5Cs*%5Cd+)%7B3,%7D%5C]$" , "ok" : " Excellent" , "error" : " Try%20adding%20a%20fourth%20number%20to%20the%20list" , "text" : " %3Cp%3ELists%20(arrays)%20store%20things%20%3Cstrong%3Ein%20some%20order%3C/strong%3E.%3C/p%3E%0A%0A%3Cp%3ELike%20standing%20in%20line%20for%20popcorn.%20You%20are%20behind%20someone%20and%20you%20wouldn’t%20dream%20of%20pushing%20them%20aside,%0Aright?%20And%20the%20guy%20behind%20you,%20you’ve%20got%20a%20close%20eye%20on%20him,%20right?%3C/p%3E%0A%0A%3Cp%3EHere’s%20a%20list%20for%20you.%20Lottery%20numbers:%20%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3E[12,%2047,%2035]%0A%3C/code%3E%3C/pre%3E%0A%0A%3Cp%3ETry%20adding%20a%20number%20to%20this%20list:%20type%20a%20comma%20after%2035%20followed%20by%20a%20number.%20The%20space%20is%20optional.%3C/p%3E%0A" , "load_code" : " " },
1414 "13" : {"lang" : " EN" , "title" : " One Raises Its Hand" , "chapter" : " N" , "answer" : " %5E47$" , "ok" : " Okay" , "error" : " " , "text" : " %3Cp%3EA%20list%20of%20lottery%20numbers.%20Which%20one%20is%20the%20highest?%3C/p%3E%0A%0A%3Cp%3ETry:%20%3C/p%3E%0A%0A%3Cpre%3E%3Ccode%3E[12,%2047,%2035].max%0A%3C/code%3E%3C/pre%3E%0A" , "load_code" : " " },
1515 "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" : " " },
5555 "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"},
5656 "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"},
5757 "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"}
58- }
58+ }
0 commit comments