Module: Cinch::BotTemplate

Defined in:
lib/cinch/bot_template/version.rb,
lib/cinch/bot_template/desc/bot.rb,
lib/cinch/bot_template/desc/gen.rb,
lib/cinch/bot_template/main/bot.rb,
lib/cinch/bot_template/main/cli.rb,
lib/cinch/bot_template/main/desc.rb,
lib/cinch/bot_template/desc/hello.rb,
lib/cinch/bot_template/classes/bot.rb,
lib/cinch/bot_template/desc/plugin.rb,
lib/cinch/bot_template/main/config.rb,
lib/cinch/bot_template/main/plugin.rb,
lib/cinch/bot_template/main/spinner.rb,
lib/cinch/bot_template/classes/hello.rb,
lib/cinch/bot_template/templates/bot.rb,
lib/cinch/bot_template/classes/config.rb,
lib/cinch/bot_template/classes/plugin.rb,
lib/cinch/bot_template/templates/hello.rb,
lib/cinch/bot_template/classes/gen_init.rb,
lib/cinch/bot_template/templates/config.rb,
lib/cinch/bot_template/templates/plugin.rb,
lib/cinch/bot_template/cinch-bot_template.rb,
lib/cinch/bot_template/classes/exceptions.rb

Defined Under Namespace

Modules: CLI, Classes, Descs, Exceptions, Templates Classes: Bot, Config, Plugin

Constant Summary collapse

VERSION =
"0.1.1"

Class Method Summary collapse

Class Method Details

.show_wait_spinner(fps = 10) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/cinch/bot_template/main/spinner.rb', line 5

def show_wait_spinner(fps = 10)
  chars   = %w[| / - \\]
  delay   = 1.0 / fps
  iter    = 0
  spinner = Thread.new do
    while iter do # Keep spinning until told otherwise
      print chars[(iter += 1) % chars.length]
      sleep delay
      print "\b"
    end
  end
  yield.tap {# After yielding to the block, save the return value
    iter = false # Tell the thread to exit, cleaning up after itself…
    spinner.join # …and wait for it to do so.
  } # Use the block's return value as the method's
end