Class List Method List File List

# Class: Concurrent::Channel::Selector::TakeClause

Inherits:
  Object
  - Object
  - Concurrent::Channel::Selector::TakeClause
  show all
Defined in:
  lib/concurrent/channel/selector/take_clause.rb

## Instance Method Summary (collapse)

- - (undocumented) execute
- - (TakeClause) initialize(channel, block) constructor

  A new instance of TakeClause.

## Constructor Details

### - (`TakeClause`) initialize(channel, block)

Returns a new instance of TakeClause

    9
    10
    11
    12

    # File 'lib/concurrent/channel/selector/take_clause.rb', line 9

    def initialize(channel, block)
      @channel = channel
      @block = block
    end

## Instance Method Details

### - (`undocumented`) execute

    14
    15
    16
    17
    18
    19
    20

    # File 'lib/concurrent/channel/selector/take_clause.rb', line 14

    def execute
      if (result = @channel.poll?).just?
        Concurrent::Maybe.just(@block.call(result.value))
      else
        Concurrent::Maybe.nothing
      end
    end