Class: TheDude::Http
- Inherits:
-
Object
- Object
- TheDude::Http
- Defined in:
- lib/the_dude/http.rb
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
The current url being visited.
Instance Method Summary collapse
-
#initialize(url = nil) ⇒ TheDude::Http
constructor
Initalizes a new instance.
-
#source ⇒ Object
Returns the HTML source for the current url.
-
#visit(url) ⇒ Object
Sets the current url.
Constructor Details
#initialize(url = nil) ⇒ TheDude::Http
Initalizes a new instance
13 14 15 |
# File 'lib/the_dude/http.rb', line 13 def initialize url=nil visit url if url end |
Instance Attribute Details
#url ⇒ Object (readonly)
The current url being visited
6 7 8 |
# File 'lib/the_dude/http.rb', line 6 def url @url end |
Instance Method Details
#source ⇒ Object
Returns the HTML source for the current url
18 19 20 21 |
# File 'lib/the_dude/http.rb', line 18 def source raise 'No url' unless @url Net::HTTP.get(URI.parse(@url)).to_s end |
#visit(url) ⇒ Object
Sets the current url
24 25 26 |
# File 'lib/the_dude/http.rb', line 24 def visit url @url = url end |