Class: Object

Inherits:
BasicObject
Defined in:
lib/core/object.rb

Instance Method Summary collapse

Instance Method Details

#change_attr(attr, val, &block) ⇒ Object

Description

Change attr to val within the scope of block and then sets it back again



22
23
24
25
26
27
28
29
30
# File 'lib/core/object.rb', line 22

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

#pool(name = nil, &block) ⇒ Object



3
4
5
# File 'lib/core/object.rb', line 3

def pool(name=nil, &block)
  @@pool ||= PoolParty::Pool.new(name, &block)
end


11
12
13
14
15
# File 'lib/core/object.rb', line 11

def print_msg(msg_arr)
  msg_arr.each do |line|
    puts line
  end
end

#progress_bar_until(msg = nil, &block) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/core/object.rb', line 32

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

#reset!Object



7
8
9
# File 'lib/core/object.rb', line 7

def reset!
  @@pool = nil
end