Class: Nokogiri::HTML::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/SitemapMaker/Nokogiri/html.rb

Overview

SitemapMaker::HTML(open(“http://…”))で返されるオブジェクトです method_missingの拡張

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, args = nil, &block) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/SitemapMaker/Nokogiri/html.rb', line 19

def method_missing(method_name, args = nil, &block)
  method_name = method_name.to_s

  # page.meta_all などのメソッドは、xpathで要素を返す
  case  method_name
  when /_all$/
    @meta_all = self.xpath("//#{method_name.sub(/_all$/, '')}")
  else
    super
  end
end