Class: Lockfile::SleepCycle

### Home Classes Methods

### In Files

- lib/lockfile.rb

### Parent

Array

### Methods

- ::new
- #next
- #reset

### Class/Module Index

Quicksearch

- Lockfile
- Lockfile::LockError
- Lockfile::MaxTriesLockError
- Lockfile::NFSLockError
- Lockfile::SleepCycle
- Lockfile::StackingLockError
- Lockfile::StatLockError
- Lockfile::StolenLockError
- Lockfile::TimeoutLockError
- Lockfile::UnLockError
- Object

No matching classes.

# Lockfile::SleepCycle

### Attributes

inc[R]
max[R]
min[R]
range[R]

### Public Class Methods

new(min, max, inc) click to toggle source

    # File lib/lockfile.rb, line 28
    def initialize(min, max, inc)
      @min, @max, @inc = Float(min), Float(max), Float(inc)
      @range = @max - @min
      raise RangeError, "max(#{ @max }) <= min(#{ @min })" if @max <= @min
      raise RangeError, "inc(#{ @inc }) > range(#{ @range })" if @inc > @range
      raise RangeError, "inc(#{ @inc }) <= 0" if @inc <= 0
      raise RangeError, "range(#{ @range }) <= 0" if @range <= 0
      s = @min
      push(s) and s += @inc while(s <= @max)
      self[-1] = @max if self[-1] < @max
      reset
    end

### Public Instance Methods

next() click to toggle source

    # File lib/lockfile.rb, line 41
    def next
      ret = self[@idx]
      @idx = ((@idx + 1) % self.size)
      ret
    end

reset() click to toggle source

    # File lib/lockfile.rb, line 47
    def reset
      @idx = 0
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.