This post originated from an RSS feed registered with Ruby Buzz
by Red Handed.
Original Post: Digging Deep with Instance_eval
Feed Title: RedHanded
Feed URL: http://redhanded.hobix.com/index.xml
Feed Description: sneaking Ruby through the system
f = open("myfile")
if f.stat.readable? and f.stat.writable? and f.stat.size? and f.stat.owned?
# work with file
end
My favorite solution involves instance_eval, but see how long and ugly it looks? Perhaps an answer would be aliasing a name like within for simple block calls to instance_eval.
f = open("myfile")
if f.stat.instance_eval{ readable? and writable? and size? and owned? }
# work with file
end