#!/usr/bin/env ruby -w # public domain class ASCIIAnim def initialize(frames, repeat = 1) @frames = frames @repeat = repeat end def each @repeat.times { @frames.each { |f| yield f } } end end ANIMATIONS = [ ASCIIAnim.new(["\\o\\", "|o|", "/o/", "|o|"], 3), ASCIIAnim.new([".o|", ".o.", "|o.", "|o|"]), ASCIIAnim.new([".o.", ".ov", ".oV", ".o."]), ASCIIAnim.new(["\\o/", "-o-", ".o.", "-o-", "\\o/", "|o|"], 2), ASCIIAnim.new(["\\o/", "-o-", "-o ", "-o-", " o-", "-o-", "\\o/", "|o|"]), ] while true do anim = ANIMATIONS[rand(ANIMATIONS.length)] anim.each { |f| print f + "\r" $stdout.flush sleep(0.5) } end