Ruby: Alias a method from a class
Let's use Nokogiri as an example.
How can I rewrite
page = Nokogiri::HTML.parse(html)
as
page = myparse(html)
I see the "alias" keyword but since it involves opening up whatever modules/classes a method belongs to, there is no uni开发者_开发技巧versal way of aliasing.
You could create a method in your application/class to wrap this for you:
def myparse(html)
Nokogiri::HTML.parse(html)
end
精彩评论