Skip to content

Instantly share code, notes, and snippets.

@wycats
Created March 10, 2011 17:08
Show Gist options
  • Save wycats/864468 to your computer and use it in GitHub Desktop.
Save wycats/864468 to your computer and use it in GitHub Desktop.
class ReadAdapter #:nodoc: internal use only
def initialize(block)
@block = block
end
def inspect
"#<#{self.class}>"
end
def <<(str)
call_block(str, &@block) if @block
end
private
# This method is needed because @block must be called by yield,
# not Proc#call. You can see difference when using `break' in
# the block.
def call_block(str)
yield str
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment