--nextPart2175644.v5JOTTBBfD
Content-Type: text/plain;
  charsetso-8859-1"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Quoth Kristoph:
> Greetings,
> 
> How might I capture the code in a block so that I can serialize it for
> later use? So for example ...
> 
> file = CodeFile.new( 'something.rb')
> 
> file.capture do
>     puts 'Hello World'
> end
> 
> ... which prompts a file to be created with ...
> 
> puts 'Hello World'
> 
> Any thoughts how this might be accomplished?

Do you actually want a literal "puts 'Hello World'" in the file, or just the 
string "Hello World"?

  def my_method &block
    @block = block
  end

  def my_other_method
    @block.call
  end

Something like that?

HTH,
-- 
Konrad Meyer <konrad / tylerc.org> http://konrad.sobertillnoon.com/

--nextPart2175644.v5JOTTBBfD
Content-Type: application/pgp-signature; name=signature.asc 
Content-Description: This is a digitally signed message part.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQBHGU/+CHB0oCiR2cwRAtv6AJ0fEwmouk6VwJtzqXA+Xf5p34gg2QCePSev
7cyCXm2/+L7vbmxmivYoFfkUK
-----END PGP SIGNATURE-----

--nextPart2175644.v5JOTTBBfD--