Class: CSteamer::Document
- Inherits:
-
Object
- Object
- CSteamer::Document
- Includes:
- InternalAttributes
- Defined in:
- lib/csteamer/document.rb
Overview
CSteamer::Document represents a single HTML document within CSteamer
Instance Attribute Summary collapse
-
#doc ⇒ Object
readonly
Returns the value of attribute doc.
Instance Method Summary collapse
-
#html ⇒ Object
An HTML representation of the document.
-
#initialize(handle) ⇒ Document
constructor
A new instance of Document.
- #load(handle) ⇒ Object
Methods included from InternalAttributes
#author, #description, #lede, #title
Constructor Details
#initialize(handle) ⇒ Document
Returns a new instance of Document.
12 13 14 |
# File 'lib/csteamer/document.rb', line 12 def initialize(handle) load(handle) end |
Instance Attribute Details
#doc ⇒ Object (readonly)
Returns the value of attribute doc.
8 9 10 |
# File 'lib/csteamer/document.rb', line 8 def doc @doc end |
Instance Method Details
#html ⇒ Object
An HTML representation of the document
17 18 19 |
# File 'lib/csteamer/document.rb', line 17 def html @doc.to_s end |
#load(handle) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/csteamer/document.rb', line 21 def load(handle) @html = if handle =~ /^http/ open(handle).read elsif handle.is_a?(StringIO) || handle.is_a?(IO) handle.read else handle end @doc = Nokogiri::HTML(@html) end |