Class: Dizby::IOBarrier

Inherits:
Object
  • Object
show all
Defined in:
lib/dizby/utility/io_barrier.rb

Instance Method Summary collapse

Constructor Details

#initialize(var) ⇒ IOBarrier

Returns a new instance of IOBarrier.


6
7
8
9
# File 'lib/dizby/utility/io_barrier.rb', line 6

def initialize(var)
  @var = var
  @orig = var.dup
end

Instance Method Details

#allow


15
16
17
18
# File 'lib/dizby/utility/io_barrier.rb', line 15

def allow
  @var.reopen(@orig)
  @var.sync = true
end

#block


11
12
13
# File 'lib/dizby/utility/io_barrier.rb', line 11

def block
  @var.reopen(File::NULL)
end