lib/ionian/extension/io.rb in ionian-0.6.3 vs lib/ionian/extension/io.rb in ionian-0.6.4
- old
+ new
@@ -104,11 +104,10 @@
@matches = []
while @ionian_buf =~ exp
@matches << $~ # Match data.
- yield $~ if block_given?
@ionian_buf = $' # Leave post match data in the buffer.
end
# Convert named captures to methods.
if build_methods
@@ -120,10 +119,13 @@
unless match.respond_to? symbol
}
end
end
+ # Pass each match to block.
+ @matches.each {|match| yield match} if block_given?
+
# Notify on_match listeners unless the #run_match thread is active.
@matches.each {|match| notify_listeners match} if notify and not @match_listener
@matches
end
@@ -158,10 +160,10 @@
end
# Register a block to be called when #run_match receives matched data.
# Method callbacks can be registered with &object.method(:method).
# Returns a reference to the given block.
- # block = ionian_socket.register_observer {...}
+ # block = ionian_socket.register_observer { ... }
def register_observer(&block)
@ionian_listeners << block unless @ionian_listeners.include? block
block
end
\ No newline at end of file