Class: Aranha::Parsers::Html::Base
  
  
  
  
  
    - Inherits:
- 
      Base
      
        
          - Object
- Base
- Aranha::Parsers::Html::Base
 show all
    - Defined in:
- lib/aranha/parsers/html/base.rb
 
Defined Under Namespace
  
    
  
    
      Classes: Field
    
  
  Constant Summary
  
  Constants inherited
     from Base
  Base::LOG_DIR_ENVVAR
  Instance Attribute Summary
  
  Attributes inherited from Base
  #source_address
  
    
      Class Method Summary
      collapse
    
    
  
    
      Instance Method Summary
      collapse
    
    
  
  
  
  
  
  
  
  
  
  Methods inherited from Base
  #content, #content_encoding, from_content, from_string, #initialize, #source_address_content
  
    Class Method Details
    
      
  
  
    .field(name, type, xpath)  ⇒ Object 
  
  
  
  
    | 
17
18
19
20 | # File 'lib/aranha/parsers/html/base.rb', line 17
def field(name, type, xpath)
  @fields ||= []
  @fields << Field.new(name, type, xpath)
end | 
 
    
      
  
  
    .fields  ⇒ Object 
  
  
  
  
    | 
12
13
14
15 | # File 'lib/aranha/parsers/html/base.rb', line 12
def fields
  @fields ||= []
  @fields.dup
end | 
 
    
      
  
  
    | 
24
25
26 | # File 'lib/aranha/parsers/html/base.rb', line 24
def from_node(node)
  from_string(node.to_html)
end | 
 
    
      
  
  
    .xpath_contains_class(klass, node = '@class')  ⇒ String 
  
  
  
  
    | 
31
32
33 | # File 'lib/aranha/parsers/html/base.rb', line 31
def xpath_contains_class(klass, node = '@class')
  "contains(concat(' ', normalize-space(#{node}), ' '), ' #{klass} ')"
end | 
 
    
      
  
  
    .xpath_ends_with(haystack, needle)  ⇒ String 
  
  
  
  
    | 
38
39
40
41 | # File 'lib/aranha/parsers/html/base.rb', line 38
def xpath_ends_with(haystack, needle)
  "substring(#{haystack}, string-length(#{haystack}) - string-length(#{needle}) + 1) " \
    "= #{needle}"
end | 
 
    
   
  
    Instance Method Details
    
      
  
  
    #nokogiri  ⇒ Object 
  
  
  
  
    | 
46
47
48 | # File 'lib/aranha/parsers/html/base.rb', line 46
def nokogiri
  @nokogiri ||= Nokogiri::HTML(content, &:noblanks)
end |