Sha256: e6c110c367eb66c4bd705a0205f63beba10cdecb23181f7fe11cea50450c96ce

Contents?: true

Size: 812 Bytes

Versions: 1

Compression:

Stored size: 812 Bytes

Contents

class Object
    
  def pool(name=nil, &block)
    @@pool ||= PoolParty::Pool.new(name, &block)
  end
  
  def reset!
    @@pool = nil
  end
  
  def print_msg(msg_arr)
    msg_arr.each do |line|
      puts line
    end
  end

  # === Description
  #
  # Change +attr+ to +val+ within the scope of block
  # and then sets it back again
  #
  def change_attr attr, val, &block
    old_val = instance_variable_get attr
    begin
      instance_variable_set attr, val
      yield
    ensure
      instance_variable_set attr, old_val
    end
  end
  
  def progress_bar_until(msg=nil, &block)
    print "#{msg}" if msg
    loop do
      if block.call
        break
      else
        $stdout.print "."
        $stdout.flush
        sleep 1
      end
    end
    print " OK" if msg
    puts "" if msg
  end
  
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
poolparty-1.6.9 lib/core/object.rb