title: Instance Eval Within Block
body: <p>I have a Builder class that lets you add to one of it's instance variables:</p>
  
  <pre><code>class Builder
      def initialize
          @lines = []
      end
  
      def lines
          block_given? ? yield(self) : @lines
      end
  
      def add_line( text )
          @lines &lt;&lt; text
      end
  end
  </code></pre>
  
  <p>Now, how do I change this</p>
  
  <pre><code>my_builder = Builder.new
  my_builder.lines { |b|
      b.add_line "foo"
      b.add_line "bar"
  }
  p my_builder.lines # =&gt; ["foo", "bar"]
  </code></pre>
  
  <p>Into this?</p>
  
  <pre><code>my_builder = Builder.new
  my_builder.lines {
      add_line "foo"
      add_line "bar"
  }
  p my_builder.lines # =&gt; ["foo", "bar"]
  </code></pre>