Class: Lock

Inherits:
Object
  • Object
show all
Defined in:
lib/lock.rb

Class Method Summary collapse

Class Method Details

.lockObject



13
14
15
# File 'lib/lock.rb', line 13

def lock
  system "touch #{@lock_file}"
end

.locked?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/lock.rb', line 9

def locked?
  File.exist? @lock_file
end

.unlockObject



17
18
19
20
# File 'lib/lock.rb', line 17

def unlock
  lock
  system "rm #{@lock_file}"
end

.use(lock_file) ⇒ Object



5
6
7
# File 'lib/lock.rb', line 5

def use lock_file
  @lock_file = lock_file
end