Created
August 27, 2012 02:52
-
-
Save nattarnoff/3485176 to your computer and use it in GitHub Desktop.
First .rb I have written without a guide. Its simple, but feels like a big win right now.
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
class Haiku | |
def initialize | |
five_syllables(1) | |
seven_syllables | |
five_syllables(0) | |
end | |
def five_syllables(line) | |
if line == 1 | |
puts "This is a haiku" | |
else | |
puts "This is the end now" | |
end | |
end | |
def seven_syllables | |
puts "This line has more syllables" | |
end | |
end | |
haiku = Haiku.new |
Good idea, but the next phase o fthis script will be fetching words and building haiku sentences.
Looks like I will use the wordnik API to fill in definition, word type (nouns, verb, etc), and syllables into a csv for the most popular words.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
One idea:
You could use a symbol instead of a magic value like 1 or 0.
five_syllables(:begin)
five_syllables(:end)
Then compare line to :begin. Same exact functionality but a bit clearer intention.