Advertisement
Guest User

Untitled

a guest
Aug 14th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.53 KB | None | 0 0
  1. require 'time'
  2.  
  3. # GMT+9 August 9, 1945 11:02am
  4. lastBoom = Time.new(1945,8,9,11,2,0,"+09:00")
  5. secSince = Time.new - lastBoom
  6. daysSince = secSince / 86400
  7.  
  8. lines = [
  9.   "+++ SAFETY FIRST +++",
  10.   "",
  11.   "This planet has gone",
  12.   "[ #{daysSince.to_i} ] DAYS",
  13.   "without a nuclear war",
  14.   "",
  15.   "+++ SAFETY FIRST +++"
  16. ]
  17. maxWidth = 0
  18. lines.each do |i|
  19.   t = i.length
  20.   maxWidth = t if t > maxWidth
  21. end
  22. maxWidth += 1 if maxWidth.odd?
  23. maxWidth += 2 # padding
  24.  
  25. puts ''
  26. lines.each do |i|
  27.   puts i.center(maxWidth)
  28. end
  29. puts ''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement