Skip to content

Instantly share code, notes, and snippets.

@5t111111
Last active August 29, 2015 14:26
Show Gist options
  • Select an option

  • Save 5t111111/63cf622b2779d6c7e0df to your computer and use it in GitHub Desktop.

Select an option

Save 5t111111/63cf622b2779d6c7e0df to your computer and use it in GitHub Desktop.
本当にひどいコードです。
class Doala
def move(number)
hand = -> (n) { n % 2 == 0 ? '⌒' : 'ー' }
f = Fiber.new do
n = 0
reverse = false
line_length = 50
loop do
line = "\r" + " " * n + '(' + hand.call(n) + '(´・△・`)' + hand.call(n) + '⌒)'
line_fill = 50 - line.length
Fiber.yield(line + " " * line_fill)
sleep 0.1
if reverse
n -= 1
else
n += 1
end
reverse = true if n == line_length / 2
reverse = false if n == 0
end
end
number.times do
print f.resume
end
end
end
Doala.new.move 200
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment