Methods

Included Modules

Hpricot::Doc::Trav

Public Instance Methods

author() click to toggle source

author searches author and return it as a text. It returns nil if not found.

author searchs following information.

  • in HTML

  • in HTML

  • author-name in RSS

  • author-name in RSS

     # File lib/hpricot/traverse.rb, line 761
761:     def author
762:       traverse_element('meta',
763:         '{http://www.w3.org/1999/xhtml}meta') {|e|
764:         begin
765:           next unless e.fetch_attr('name').downcase == 'author'
766:           author = e.fetch_attribute('content').strip
767:           return author if !author.empty?
768:         rescue IndexError
769:         end
770:       }
771: 
772:       traverse_element('link',
773:         '{http://www.w3.org/1999/xhtml}link') {|e|
774:         begin
775:           next unless e.fetch_attr('rev').downcase == 'made'
776:           author = e.fetch_attribute('title').strip
777:           return author if !author.empty?
778:         rescue IndexError
779:         end
780:       } 
781: 
782:       if channel = find_element('{http://purl.org/rss/1.0/}channel')
783:         channel.traverse_element('{http://purl.org/dc/elements/1.1/}creator') {|e|
784:           begin
785:             author = e.extract_text.strip
786:             return author if !author.empty?
787:           rescue IndexError
788:           end
789:         }
790:         channel.traverse_element('{http://purl.org/dc/elements/1.1/}publisher') {|e|
791:           begin
792:             author = e.extract_text.strip
793:             return author if !author.empty?
794:           rescue IndexError
795:           end
796:         }
797:       end
798: 
799:       nil
800:     end
root() click to toggle source
     # File lib/hpricot/traverse.rb, line 805
805:     def root
806:       es = []
807:       children.each {|c| es << c if c.elem? } if children
808:       raise Hpricot::Error, "no element" if es.empty?
809:       raise Hpricot::Error, "multiple top elements" if 1 < es.length
810:       es[0]
811:     end
title() click to toggle source

title searches title and return it as a text. It returns nil if not found.

title searchs following information.

  • in HTML

  • in RSS

     # File lib/hpricot/traverse.rb, line 744
744:     def title
745:       e = find_element('title',
746:         '{http://www.w3.org/1999/xhtml}title',
747:         '{http://purl.org/rss/1.0/}title',
748:         '{http://my.netscape.com/rdf/simple/0.9/}title')
749:       e && e.extract_text
750:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.