Class: Delayer::Procedure

### Home Classes Methods

### In Files

- lib/delayer/procedure.rb

### Parent

Object

### Methods

- ::new
- #break
- #cancel
- #canceled?
- #run

### Class/Module Index

Quicksearch

- Delayer
- Delayer::AlreadyCanceledError
- Delayer::AlreadyExecutedError
- Delayer::AlreadyRunningError
- Delayer::Error
- Delayer::Extend
- Delayer::InvalidPriorityError
- Delayer::Priority
- Delayer::Priority::Extend
- Delayer::Procedure
- Delayer::TooLate

No matching classes.

# Delayer::Procedure

### Attributes

delayer[R]
next[RW]
state[R]

### Public Class Methods

new(delayer, &proc) click to toggle source

    # File lib/delayer/procedure.rb, line 6
    def initialize(delayer, &proc)
      @delayer, @proc = delayer, proc
      @state = :stop
      @next = nil
      @delayer.class.register(self)
    end

### Public Instance Methods

break(node) click to toggle source

insert node between self and self.next

#### Args

node

  insertion

#### Return

node

    # File lib/delayer/procedure.rb, line 53
    def break(node)
      tail = @next
      @next = node
      node.next = tail
      node
    end

cancel() click to toggle source

Cancel this job

#### Exception

Delayer::TooLate | if already called run()

#### Return

self

    # File lib/delayer/procedure.rb, line 33
    def cancel
      unless :stop == @state
        raise Delayer::StateError(@state), "cannot cancel Delayer::Procedure"
      end
      @state = :cancel
      self
    end

canceled?() click to toggle source

Return true if canceled this task

#### Return

true if canceled this task

    # File lib/delayer/procedure.rb, line 44
    def canceled?
      :cancel == @state
    end

run() click to toggle source

Run a process

#### Exception

Delayer::TooLate | if already called run()

#### Return

node

    # File lib/delayer/procedure.rb, line 18
    def run
      unless :stop == @state
        raise Delayer::StateError(@state), "call twice Delayer::Procedure"
      end
      @state = :run
      @proc.call
      @state = :done
      @proc = nil
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.