Method: Window#static

Defined in:
lib/drydock/console.rb

#static(type, refresh = 2, props = {}, &b) ⇒ Object

Print text to the screen via type every refresh seconds. Print the return value of the block to the screen using the print_type method. refresh is number of seconds to wait props is the hash sent to print_type. Returns a Thread object.

# Print the time in the upper right corner every second
thread1 = Console.static(:right, 1, {:y => 0}) do 
  Time.now.utc.strftime("%Y-%m-%d %H:%M:%S").colour(:blue, :white, :underline)
end


284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
# File 'lib/drydock/console.rb', line 284

def static(type, refresh=2, props={}, &b)
  meth = "print_#{type}"
  raise "#{meth} is not supported" unless Console.respond_to?(meth)
  
  refresh ||= 0
  refreh = refresh.to_s.to_i
  
  thread = every_n_seconds(refresh) do 
    Console.send(meth, b.call, props.clone) 
  end
  
  @threads << thread
  
  thread
end