Class: Hegel::Stateful::Pool::ValuesConsumed

Inherits:
Generator
  • Object
show all
Defined in:
lib/hegel/stateful/pool.rb,
sig/hegel.rbs

Overview

Hegel::Generator returned by Pool#values_consumed. Same reasoning as ValuesReusable above for staying un-namespaced and for not pre-checking emptiness.

Instance Method Summary collapse

Methods inherited from Generator

#filter, #map

Constructor Details

#initialize(pool, values) ⇒ ValuesConsumed

Returns a new instance of ValuesConsumed.

Parameters:

  • pool (Object)
  • values (Hash[Integer, untyped])


96
97
98
99
100
# File 'lib/hegel/stateful/pool.rb', line 96

def initialize(pool, values)
  super()
  @pool = pool
  @values = values
end

Instance Method Details

#do_draw(tc) ⇒ Object

Parameters:

  • tc (Object)

Returns:

  • (Object)


102
103
104
105
106
107
# File 'lib/hegel/stateful/pool.rb', line 102

def do_draw(tc)
  variable_id = tc.pool_generate(@pool, true)
  value = @values.fetch(variable_id)
  @values.delete(variable_id)
  value
end