Class: ProxyFetcher::Document::Node
- Inherits:
- 
      Object
      
        - Object
- ProxyFetcher::Document::Node
 
- Defined in:
- lib/proxy_fetcher/document/node.rb
Overview
Abstract class for storing HTML elements that was parsed by one of the ProxyFetcher::Document adapters class.
Direct Known Subclasses
ProxyFetcher::Document::NokogiriAdapter::Node, OgaAdapter::Node
Instance Attribute Summary collapse
- 
  
    
      #node  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute node. 
Instance Method Summary collapse
- 
  
    
      #at_css(*args)  ⇒ ProxyFetcher::Document::Node 
    
    
  
  
  
  
  
  
  
  
  
    Searches exact HTML element by CSS. 
- 
  
    
      #at_xpath(*args)  ⇒ ProxyFetcher::Document::Node 
    
    
  
  
  
  
  
  
  
  
  
    Searches exact HTML element by XPath. 
- 
  
    
      #content  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Returns HTML node content. 
- 
  
    
      #content_at(*args)  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    Returns clean content (text) for the specific element. 
- 
  
    
      #find(selector, method = :at_xpath)  ⇒ Node 
    
    
  
  
  
  
  
  
  
  
  
    Searches for node in children using some selector (CSS or XPath). 
- 
  
    
      #html  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Returns HTML node inner HTML. 
- 
  
    
      #initialize(node)  ⇒ Node 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    Initialize new HTML node. 
Constructor Details
#initialize(node) ⇒ Node
Initialize new HTML node
| 16 17 18 | # File 'lib/proxy_fetcher/document/node.rb', line 16 def initialize(node) @node = node end | 
Instance Attribute Details
#node ⇒ Object (readonly)
Returns the value of attribute node.
| 10 11 12 | # File 'lib/proxy_fetcher/document/node.rb', line 10 def node @node end | 
Instance Method Details
#at_css(*args) ⇒ ProxyFetcher::Document::Node
Searches exact HTML element by CSS. Returns only one element.
| 44 45 46 | # File 'lib/proxy_fetcher/document/node.rb', line 44 def at_css(*args) self.class.new(node.at_css(*args)) end | 
#at_xpath(*args) ⇒ ProxyFetcher::Document::Node
Searches exact HTML element by XPath. Returns only one element.
| 35 36 37 | # File 'lib/proxy_fetcher/document/node.rb', line 35 def at_xpath(*args) self.class.new(node.at_xpath(*args)) end | 
#content ⇒ Object
Returns HTML node content.
Abstract method, must be implemented for specific adapter class.
| 61 62 63 | # File 'lib/proxy_fetcher/document/node.rb', line 61 def content raise "`#{__method__}` must be implemented for specific adapter class!" end | 
#content_at(*args) ⇒ String
Returns clean content (text) for the specific element.
| 53 54 55 | # File 'lib/proxy_fetcher/document/node.rb', line 53 def content_at(*args) clear(find(*args).content) end | 
#find(selector, method = :at_xpath) ⇒ Node
Searches for node in children using some selector (CSS or XPath).
| 26 27 28 | # File 'lib/proxy_fetcher/document/node.rb', line 26 def find(selector, method = :at_xpath) self.class.new(node.public_send(method, selector)) end | 
#html ⇒ Object
Returns HTML node inner HTML.
Abstract method, must be implemented for specific adapter class.
| 69 70 71 | # File 'lib/proxy_fetcher/document/node.rb', line 69 def html raise "`#{__method__}` must be implemented for specific adapter class!" end |