Skip to content

Typographic spacing fixes in English #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions source/try_ruby_en.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions translations/en/try_ruby_170.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.

Expand Down
4 changes: 2 additions & 2 deletions translations/en/try_ruby_180.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions translations/en/try_ruby_230.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -24,7 +24,7 @@ methods is <a href="http://ruby-doc.org/core/classes/String.html" target="_blank

Go ahead and try a few, such as: poem.downcase or poem.swapcase

## Ready ?
## Ready?
When you feel ready to move on, type:

books = {}
18 changes: 9 additions & 9 deletions translations/en/try_ruby_320.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
---
lang: EN
title: To (be) or not to (be)
answer:
answer:
load: poem = "My toast has flown from my hand\nAnd my toast has gone to the moon.\nYada yada yada\n"
ok:
error:
ok:
error:
---

One other little thing we haven't really talked about openly: method arguments.
Remember when we changed the poem a little bit ? We used:
Remember when we changed the poem a little bit? We used:
__poem.gsub("toast", "honeydew")__

The gsub method needs 2 arguments, which we passed to gsub by including two strings between
parenthesis. _Arguments tell the method exactly what to do._

### Parenthesis
Actually, most of the time Ruby doesn't mind if you omit the parenthesis. So this would have
worked too:
worked too:
__poem.gsub "toast", "honeydew"__

We have already used another method with a parameter. Many times in fact, though it was not very
obvious:

puts "Hello"
puts("Hello")

Yes __puts__ is also a method. Using puts with or without parenthesis is the same to Ruby, but the
version without parenthesis is a bit easier to read. And it saves you valuable typing time !
version without parenthesis is a bit easier to read. And it saves you valuable typing time!

> So I guess the conclusion is that you can do whatever you like with parenthesis as long as your
> code reads nicely.
Expand All @@ -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.
6 changes: 3 additions & 3 deletions translations/en/try_ruby_330.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
6 changes: 3 additions & 3 deletions translations/en/try_ruby_360.md
Original file line number Diff line number Diff line change
Expand Up @@ -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__.
Expand All @@ -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
Expand All @@ -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!
8 changes: 4 additions & 4 deletions translations/en/try_ruby_370.md
Original file line number Diff line number Diff line change
@@ -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!
Expand All @@ -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?
6 changes: 3 additions & 3 deletions translations/en/try_ruby_40.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ 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.
> __But only the last result.__ And only if the output is still empty.

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:
Expand Down
2 changes: 1 addition & 1 deletion translations/en/try_ruby_410.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!
8 changes: 4 additions & 4 deletions translations/en/try_ruby_440.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions translations/en/try_ruby_450.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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.
Expand All @@ -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
12 changes: 6 additions & 6 deletions translations/en/try_ruby_460.md
Original file line number Diff line number Diff line change
@@ -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" &mdash; 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?

### Blurbalizer<sup>TM</sup>
You just had a brilliant idea for a new app. It is going to be __the__ next instant
Expand All @@ -22,11 +22,11 @@ these messages Blurbs<sup>TM</sup>. A Blurb<sup>TM</sup> has a maximum length of
Well, you might store your Blurbs<sup>TM</sup> 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
Expand Down
6 changes: 3 additions & 3 deletions translations/en/try_ruby_540.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 Blurbalizer<sup>TM</sup> class does ?
There you are. Did you figure out what all that code in the Blurbalizer<sup>TM</sup> class does?

> In the Blurbalizer<sup>TM</sup> class are two __methods__ (add\_a\_blurb and show\_timeline).
> You can use a method outside the class, just like we did with accessors.
Expand All @@ -20,5 +20,5 @@ Blurbalizer<sup>TM</sup> class. This way we can be sure all our Blurbs<sup>TM</s
myapp object.

myapp.add_a_blurb :moody, "Add Blurb here"

myapp.show_timeline
20 changes: 10 additions & 10 deletions translations/en/try_ruby_550.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
lang: EN
title: It's All About Combining
answer: :-
ok: Moody !
error:
ok: Moody!
error:
load: prev
---

Some beautiful things can be done with the simple parts of Ruby, especially when you combine them
together into new things.
together into new things.
Here we've got an app made of a class containing another class. And, actually, Ruby really does good
with this kind of creature. It is called object oriented programming.

Expand All @@ -20,13 +20,13 @@ a _moodify_ method to the Blurb<sup>TM</sup> 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 ":-("
Expand All @@ -39,26 +39,26 @@ a _moodify_ method to the Blurb<sup>TM</sup> 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|
puts "#{t.content.ljust(40)} #{t.time}"
}
end
end

myapp.show_timeline