Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/ruby
- # GPML: you are only allowed to use this code to murder people the author
- # doesn't care about. any other use strictly prohibited.
- OPEN_SUPER, CLOSE_SUPER = "[super]", "[/super]"
- OPEN_SUB, CLOSE_SUB = "[sub]", "[/sub]"
- class String
- def to_wave(height = rand(5) - 3, direction = rand(2))
- increment = (direction == 1 ? 1 : -1)
- waved = ""
- each_char do |char|
- waved += (height > 0 ? OPEN_SUPER : OPEN_SUB) * height.abs
- waved += char
- waved += (height > 0 ? CLOSE_SUPER : CLOSE_SUB) * height.abs
- increment *= -1 if height == 3 || height == -4
- height += increment
- end
- waved
- end
- end
- if __FILE__ == $PROGRAM_NAME
- if ARGV
- puts ARGV.join(" ").to_wave
- else
- puts "Welcome to the Ruby Wave Bitches".to_wave
- end
- end
Add Comment
Please, Sign In to add comment