Class: XfnStone::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/xfn_stone/document.rb

Overview

This is an empty subclass of hpricot. Substuting a different XML parser in the future will be easier this way. Also a useful spot for future helpers.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.create_from_uri(uri) ⇒ Object



20
21
22
23
24
# File 'lib/xfn_stone/document.rb', line 20

def self.create_from_uri(uri)
  document = Document.new
  document.load_from_uri(uri)
  return document
end

.open(url) ⇒ Object

allow the open-uri call to be stubed



36
37
38
# File 'lib/xfn_stone/document.rb', line 36

def self.open(url)
  Kernel.open(url)
end

Instance Method Details

#elements(xpath) ⇒ Object



31
32
33
# File 'lib/xfn_stone/document.rb', line 31

def elements(xpath)
  (@document/xpath)
end

#load_from_uri(uri) ⇒ Object



26
27
28
29
# File 'lib/xfn_stone/document.rb', line 26

def load_from_uri(uri)
  file = Document.open(uri.to_s)
  @document = Hpricot(file)
end