------art_6942_16995944.1170407099819
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

2007/2/2, Jan Svitok <jan.svitok / gmail.com>:
>
> On 2/2/07, Andrea Maschio <andrea.maschio / gmail.com> wrote:
> > Well, that seems to be exactly what i was looking for, thank you Brian.
> So i
> > think i could give erb every line to parse or make him parse the entire
> file
> > before output it on the screen, right?
> > now, i've got a little question more.
> >
> > Let's say i have a class, Foo, who calls a method of another class to
> print
> > the output. For example
> >
> > class Foo
> >
> > @w
> > @myvar
> >
> >
> > def initialize
> >    witer.new
> > end
> >
> > def print_something
> -    w.put_on_screen(1)
> +     w.put_on_screen(1, binding)
> > end
> > end
> >
> > class Writer
> -  def put_on_screen(number)
> +  def put_on_screen(number, bPLEVEL_BINDING)
> >     fileðìe.open("./screens/screen#{number}","r")
> >             file.each do |line|
> >               eߣ.new(line)
> -               puts e.result
> +              puts e.result(b)
> >             end
> >  end
> > end
> >
> > in the txt file, how can i make visible @myvar to print it on the
> screen?
>
> ERB#result has another parameter, where you can pass binding - the
> vars in the file will be evaluated in that context (see
> http://ruby-doc.org/core/classes/ERB.html#M002835)



wow, that's great!  I didn't understand very well how the method binding
passes that instance variables, it seems that passing a binding object is
like passing an array of instance variable of the object  for which it is
called?

I've tried to look up in the docs, but i didn' find a clear explanation.

Thanks a lot




-- 

Andrea Maschio

http://www.superandrew.it

"The real problem is not whether machines think but whether men do."
(B. F. Skinner )

------art_6942_16995944.1170407099819--