forked from ruby/TryRuby
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Avery <>
- Loading branch information
Showing
7 changed files
with
88 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,42 @@ | ||
--- | ||
lang: EN | ||
title: Not a School Class, a Working Class | ||
lang: DE | ||
title: Keine Schulklasse, eine Arbeiterklasse | ||
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? | ||
Du siehst, die leeren geschweiften Klammern {} sind eine Abkürzung für | ||
Hash.new. Die Methode new wird verwendet, um Objekte einer bestimmten Klasse | ||
zu erzeugen. Denken Sie bei "Klasse" an die " Arbeiterklasse" — eine | ||
bestimmte Gruppe von Objekten, die ähnlich sind, die gleichen Jobs haben, die | ||
gleichen Hemden. | ||
Welchen Nutzen hat eine Klasse? | ||
|
||
### Blurbalizer<sup>TM</sup> | ||
You just had a brilliant idea for a new app. It is going to be __the__ next instant | ||
messaging platform. You want an app where people can send each other short messages. You call | ||
these messages Blurbs<sup>TM</sup>. A Blurb<sup>TM</sup> has a maximum length of just 40 characters. Let's do a mood setting too. | ||
Du hattest gerade eine brillante Idee für eine neue App. Es wird __die__ | ||
nächste Instant-Messaging-Plattform sein. Du willst eine App, mit der man sich | ||
gegenseitig kurze Nachrichten schicken kann. Du nennst diese Nachrichten | ||
Blurbs<sup>TM</sup>. Ein Blurb<sup>TM</sup> hat eine maximale Länge von nur 40 | ||
Zeichen. Lass uns auch eine Stimmungsanzeige machen. | ||
|
||
<!---The Internet has really brought back stick people and smileys out of bankruptcy. __Emote!__--> | ||
<!---Das Internet hat die Strichmännchen und Smileys wirklich aus der | ||
Versenkung geholt. __Emote!__--> | ||
|
||
### Where to start | ||
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? | ||
### Wo soll ich anfangen? | ||
Nun, du könntest deine Blurbs<sup>TM</sup>-Einträge in einer json-Datei | ||
speichern, oder? | ||
Aber wie kannst du den Inhalt des Eintrags und die Zeit, zu der er | ||
veröffentlicht wurde, nachverfolgen? | ||
Und wenn du die Datei geladen hast, wie würde sie in Ruby aussehen? | ||
Wäre es ein Hash? Oder ein Array? Oder ein Array von Arrays? Oder etwas | ||
anderes? | ||
|
||
### Class | ||
I really think you'll want to use a class. You are already familiar with many classes: | ||
### Klasse | ||
Ich glaube wirklich, dass du eine Klasse benutzen willst. Du bist bereits mit | ||
vielen Klassen vertraut: | ||
Hash, Array, String. | ||
Let's make a new class (returns no output): | ||
Erstellen wir eine neue Klasse (gibt keine Ausgabe zurück): | ||
|
||
class Blurb | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,22 @@ | ||
--- | ||
lang: EN | ||
title: The Stuff Apps are Made of | ||
lang: DE | ||
title: Der Stoff, aus dem Apps gemacht sind | ||
answer: | ||
ok: | ||
error: | ||
--- | ||
|
||
You've opened up a new Blurb<sup>TM</sup> class. What is your blog entry made of? | ||
The content, sure. Also, a time when the Blurb<sup>TM</sup> was posted. And a mood. | ||
Du hast eine neue Blurb<sup>TM</sup>-Klasse eröffnet. Woraus ist dein | ||
Blogeintrag gemacht? | ||
Der Inhalt, sicher. Auch eine Zeit, zu der der Blurb<sup>TM</sup> | ||
veröffentlicht wurde. Und eine Stimmung. | ||
|
||
Okay, so you've got the first line of the class, here's the rest: | ||
Okay, du hast also die erste Zeile der Klasse, hier ist der Rest: | ||
|
||
class Blurb | ||
attr_accessor :content, :time, :mood | ||
end | ||
|
||
Class names always begin with a capital letter. | ||
Klassennamen beginnen immer mit einem Großbuchstaben. | ||
|
||
(Still no output) | ||
(Immer noch keine Ausgabe) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,30 @@ | ||
--- | ||
lang: EN | ||
title: You've Taught Your App to Reject Worthless Things | ||
lang: DE | ||
title: Du hast deiner App beigebracht, wertlose Dinge abzulehnen | ||
answer: Blurb: | ||
ok: Blurb added | ||
error: | ||
load: class Blurb;attr_accessor :content,:time,:mood;def initialize(mood, content="");@time=Time.now;@content=content[0..39];@mood=mood;end;end;blurb1=Blurb.new(:sick,"Today Mount Hood Was Stolen!") | ||
--- | ||
|
||
Did you see how inside the class we used the at-symbols (@time). | ||
Hast du gesehen, wie wir innerhalb der Klasse die at-Symbole (@time) verwendet | ||
haben? | ||
|
||
__Outside__ the class, we use accessors: | ||
__Außerhalb__ der Klasse verwenden wir Accessors: | ||
|
||
> __blurb.time = Time.now__ | ||
but __inside__ we use the __object's variables__: | ||
aber __innerhalb__ verwenden wir die __Objektvariablen__: | ||
|
||
> __@time = Time.now__ | ||
They're the exact same thing, but expressed in two different places of your program. | ||
Sie sind genau dasselbe, werden aber an zwei verschiedenen Stellen in deinem | ||
Programm verwendet. | ||
|
||
### Create another Blurb<sup>TM</sup> | ||
When a new Blurb<sup>TM</sup> is created, the initialize method is used to check for any | ||
arguments to new. | ||
### Erstelle einen weiteren Blurb<sup>TM</sup> | ||
Wenn ein neuer Blurb<sup>TM</sup> erstellt wird, überprüft die Methode | ||
initialize, ob irgendwelche Argumente für new gibt. | ||
|
||
Uh, we need two arguments: | ||
Äh, wir brauchen zwei Argumente: | ||
|
||
Blurb2 = Blurb.new :confused, "I can not believe Mt. Hood was stolen!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,30 @@ | ||
--- | ||
lang: EN | ||
title: A Giraffe Has Not Stolen Summary #7 | ||
lang: DE | ||
title: Eine Giraffe hat nicht die Zusammenfassung #7 gestohlen | ||
answer: | ||
class: stretcher chapmark | ||
ok: | ||
error: | ||
load: prev;blurb2=Blurb.new :confused, "I can not believe Mt. Hood was stolen!" | ||
--- | ||
|
||
Aha, you're here. And all in one piece. We're still going to make your app real, | ||
but until then, let's review, okay? | ||
Aha, du bist hier. Und alles in einem Stück. Wir werden deine App immer noch | ||
verwirklichen, aber bis dahin, lass uns eine Zusammenfassung anschauen, okay? | ||
|
||
### Classes | ||
Everything in Ruby is some kind of object. Classes explain objects, how a certain object works. | ||
For example, you made a few Blurb<sup>TM</sup> objects and these objects are explained in the Blurb | ||
class. | ||
In other words: you call them Blurb objects. | ||
You can use classes to (kinda) model real life objects. | ||
### Klassen | ||
In Ruby ist alles eine Art von Objekt. Klassen erklären Objekte, wie ein | ||
bestimmtes Objekt funktioniert. | ||
Du hast zum Beispiel ein paar Blurb<sup>TM</sup>-Objekte erstellt, und diese | ||
Objekte werden in der Blurb Klasse erklärt. | ||
Mit anderen Worten: sie heißen Blurb-Objekte. | ||
Mit Klassen kann man (irgendwie) Objekte des wirklichen Lebens modellieren. | ||
|
||
### Accessors | ||
Accessors are variables attached to an object which can be used __outside__ the object. | ||
Accessors sind Variablen, die an ein Objekt angehängt sind und __außerhalb__ | ||
des Objekts verwendet werden können. | ||
(blurb2.time = Time.now) | ||
|
||
### Object variables | ||
Object variables are the same variables you're using for accessors, but __inside__ the object. | ||
### Objectvariablen | ||
Objektvariablen sind die gleichen Variablen, die man auch für Accessors | ||
verwendet, aber __innerhalb__ des Objekts. | ||
(@time = Time.now) |