Ruby module given arguments calls a method?

Viewed 717

I'm confused about what's going on in the Nokogiri docs.

As far as I can tell, if

require 'nokogiri'
some_html = "<html><body><h1>Mr. Belvedere Fan Club</h1></body></html>"

then these three lines do the same thing:

html_doc = Nokogiri::HTML::Document.parse(some_html)
html_doc = Nokogiri::HTML.parse(some_html)
html_doc = Nokogiri::HTML(some_html)

The second is just a convenience method for the first. But to my non-Ruby eyes, the third looks like it's passing an argument to a module, not a method. I realize that Ruby has constructors, but I thought they took the form Class.new, not Module(args). What's going on here?

1 Answers
Related