Class: Lernen::System::BlockSUL

Inherits:
MooreLikeSUL show all
Defined in:
lib/lernen/system/block_sul.rb

Overview

BlockSUL is a system under learning (SUL) constructed from a block.

A block is expected to behave like a membership query.

Instance Method Summary collapse

Methods inherited from SUL

#query, #query_last, #shutdown, #stats

Constructor Details

#initialize(cache: true, &block) ⇒ BlockSUL

: (?cache: bool) { (Array) -> Out } -> void



17
18
19
20
21
22
# File 'lib/lernen/system/block_sul.rb', line 17

def initialize(cache: true, &block)
  super(cache:)

  @block = block
  @word = []
end

Instance Method Details

#query_emptyObject



36
37
38
# File 'lib/lernen/system/block_sul.rb', line 36

def query_empty
  @block.call([])
end

#setupObject



25
26
27
# File 'lib/lernen/system/block_sul.rb', line 25

def setup
  @word = []
end

#step(input) ⇒ Object



30
31
32
33
# File 'lib/lernen/system/block_sul.rb', line 30

def step(input)
  @word << input
  @block.call(@word)
end