Class: Tupelo::Client::WaiterBase

Inherits:
Object
  • Object
show all
Defined in:
lib/tupelo/client/reader.rb

Direct Known Subclasses

Matcher, Waiter

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(template, client, once = true) ⇒ WaiterBase

Returns a new instance of WaiterBase.



61
62
63
64
65
66
# File 'lib/tupelo/client/reader.rb', line 61

def initialize template, client, once = true
  @template = template
  @queue = client.make_queue
  @client = client
  @once = once
end

Instance Attribute Details

#onceObject (readonly)

Returns the value of attribute once.



59
60
61
# File 'lib/tupelo/client/reader.rb', line 59

def once
  @once
end

#queueObject (readonly)

Returns the value of attribute queue.



58
59
60
# File 'lib/tupelo/client/reader.rb', line 58

def queue
  @queue
end

#templateObject (readonly)

Returns the value of attribute template.



57
58
59
# File 'lib/tupelo/client/reader.rb', line 57

def template
  @template
end

Instance Method Details

#gloms(tuple) ⇒ Object



68
69
70
71
72
73
74
# File 'lib/tupelo/client/reader.rb', line 68

def gloms tuple
  if template === tuple
    peek tuple
  else
    false
  end
end

#inspectObject



88
89
90
# File 'lib/tupelo/client/reader.rb', line 88

def inspect
  "<#{self.class}: #{template.inspect}>"
end

#peek(tuple) ⇒ Object



76
77
78
79
# File 'lib/tupelo/client/reader.rb', line 76

def peek tuple
  queue << tuple
  once
end

#waitObject



81
82
83
84
85
86
# File 'lib/tupelo/client/reader.rb', line 81

def wait
  @client.log.debug {"waiting for #{inspect}"}
  r = queue.pop
  @client.log.debug {"finished waiting for #{inspect}"}
  r
end