Guest User

Untitled

a guest
Jul 15th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #!/usr/bin/ruby
  2.  
  3. # GPML: you are only allowed to use this code to murder people the author
  4. # doesn't care about. any other use strictly prohibited.
  5.  
  6. OPEN_SUPER, CLOSE_SUPER = "[super]", "[/super]"
  7. OPEN_SUB, CLOSE_SUB = "[sub]", "[/sub]"
  8.  
  9. class String
  10. def to_wave(height = rand(5) - 3, direction = rand(2))
  11. increment = (direction == 1 ? 1 : -1)
  12. waved = ""
  13. each_char do |char|
  14. waved += (height > 0 ? OPEN_SUPER : OPEN_SUB) * height.abs
  15. waved += char
  16. waved += (height > 0 ? CLOSE_SUPER : CLOSE_SUB) * height.abs
  17.  
  18. increment *= -1 if height == 3 || height == -4
  19. height += increment
  20. end
  21. waved
  22. end
  23. end
  24.  
  25. if __FILE__ == $PROGRAM_NAME
  26. if ARGV
  27. puts ARGV.join(" ").to_wave
  28. else
  29. puts "Welcome to the Ruby Wave Bitches".to_wave
  30. end
  31. end
Add Comment
Please, Sign In to add comment