Is it possible to use the method open on my Parser class? It seems that the method is conflicting with IO::open?
class Parser
require 'nokogiri'
def parse
doc = open "someFile.html"
# Get to parsin' ...
end
def open str
Nokogiri::HTML(open(str))
end
end
parser = Parser.new
parser.parse
When I run the script I get this error:
$ ruby parser.rb
parser.rb:10: stack level too deep (SystemStackError)
I've tried a variety of things, but the only thing that seems to work is to rename Parser::open to something other than open, like docopen
I'm trying to understand how ruby works, so any further explanation beyond the answer is greatly appreciated!