Sha256: efc0e40b07ca845fa815c6c722c5ac4d30db68702c1f52938751e0b6dfc357f6

Contents?: true

Size: 685 Bytes

Versions: 19

Compression:

Stored size: 685 Bytes

Contents

require 'hpricot'

module Hpricot::IMWExtensions

  # Return the contents of the first element to match +path+.
  def contents_of path
    cnts = self.at path
    cnts.inner_html if cnts
  end

  # Return the value of +attr+ for the first element to match +path+.
  def path_attr path, attr
    cnts = self.at path
    cnts.attributes[attr] if cnts
  end

  # Return the value of the +class+ attribute of the first element to
  # match +path+.
  def class_of path
    self.path_attr(path, 'class')
  end
end

class Hpricot::Elem
  include Hpricot::IMWExtensions
end

class Hpricot::Elements
  include Hpricot::IMWExtensions
end

class Hpricot::Doc
  include Hpricot::IMWExtensions
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
imw-0.2.18 lib/imw/utils/extensions/hpricot.rb
imw-0.2.17 lib/imw/utils/extensions/hpricot.rb
imw-0.2.16 lib/imw/utils/extensions/hpricot.rb
imw-0.2.15 lib/imw/utils/extensions/hpricot.rb
imw-0.2.14 lib/imw/utils/extensions/hpricot.rb
imw-0.2.13 lib/imw/utils/extensions/hpricot.rb
imw-0.2.12 lib/imw/utils/extensions/hpricot.rb
imw-0.2.11 lib/imw/utils/extensions/hpricot.rb
imw-0.2.10 lib/imw/utils/extensions/hpricot.rb
imw-0.2.9 lib/imw/utils/extensions/hpricot.rb
imw-0.2.8 lib/imw/utils/extensions/hpricot.rb
imw-0.2.7 lib/imw/utils/extensions/hpricot.rb
imw-0.2.6 lib/imw/utils/extensions/hpricot.rb
imw-0.2.5 lib/imw/utils/extensions/hpricot.rb
imw-0.2.4 lib/imw/utils/extensions/hpricot.rb
imw-0.2.3 lib/imw/utils/extensions/hpricot.rb
imw-0.2.2 lib/imw/utils/extensions/hpricot.rb
imw-0.2.1 lib/imw/utils/extensions/hpricot.rb
imw-0.2.0 lib/imw/utils/extensions/hpricot.rb