On Sat, Feb 8, 2014 at 4:51 PM, Himel Sarkar <hsarkar.007 / gmail.com> wrote:

>
> fo = File.open("testfile.odt", "w") do |file|
>  file
> .write("So basically we're just testing this motherfucking thing. This is
> the second line. And this is the third.")
> end
>
>
Well the reason you are getting this error is because. fo doesn't has the
file object instead it has the value return from the block you ran. For the
function lineno to work you need do these two operation separately.



> line = fo.lineno
>

The right code would be:

fo = File.open("testfile.odt", "w")
fo
.write("So basically we're just testing this motherfucking thing. This is
the second line. And this is the third.")
line = fo.lineno

puts line

http://csnipp.com/coderhs/83




-- 
Harisankar P S
https://twitter.com/coder_hsps | http://tech.hsps.in