ScreenCast 5: Web 2.0 Names
Rubyology
English - March 28, 2007 22:44 - ★★★★★ - 7 ratingsTechnology Education How To Homepage Apple Podcasts Google Podcasts Overcast Castro Pocket Casts RSS feed
Previous Episode: Rubyology 4: AJAX
Next Episode: ScreenCast 6: WhoIs
This Rubyology screencast will focus on the Ruby random function and should serve as a refresher on arrays and hashes as well as looping.
The source code to our example is provided below:
# Rubyology Screencast - Web 2.0 Name Randomizer
10.times do
letters = { ?v => 'aeiou', ?c => 'bcdfghjklmnpqrstvwxyz'}
word = ''
'cvcvc'.each_byte do |x|
source = letters[x]
word << source[rand(source.length)].chr
end
puts word + '.com'
end