SHARE
TWEET

Beer Song!

jessicakennedy1028 Sep 14th, 2018 (edited) 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. puts; puts "   It's beer song time!"; puts
  2.  
  3. @count = 99
  4. @container = "bottle"
  5. @getDrunkBy = @count - 10
  6.  
  7. def bottles(n, container)
  8.   n == 1 ? "#{n} #{container}" : "#{n} #{container}s"
  9. end
  10.  
  11. def getDrunk(str, n, by)
  12.   by <= n ? str : str.split(' ').shuffle.join(' ').capitalize
  13. end
  14.  
  15.  
  16. @count.downto(1) {
  17.   puts <<BEERSONG
  18. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  19.    #{bottles(@count, @container)} of beer on the wall
  20.    #{bottles(@count, @container)} of beer
  21.    #{getDrunk('Take one down pass it around', @count, @getDrunkBy)}
  22.    #{bottles(@count -= 1, @container)} of beer on the wall
  23. BEERSONG
  24. }
  25.  
  26. puts "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
  27. puts; puts "   No more beer on the wall :-("
  28. puts "   And I'm on the floor"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top