Class: Wagon::Page
- Inherits:
-
Object
- Object
- Wagon::Page
- Defined in:
- lib/wagon/page.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #get(*args) ⇒ Object
-
#initialize(connection, url, parent = nil) ⇒ Page
constructor
A new instance of Page.
- #method_missing(method, *args, &block) ⇒ Object
- #post(*args) ⇒ Object
Constructor Details
#initialize(connection, url, parent = nil) ⇒ Page
Returns a new instance of Page.
7 8 9 10 11 12 |
# File 'lib/wagon/page.rb', line 7 def initialize(connection, url, parent = nil) @connection, @url, @parent = connection, url, parent @source = Future(@url) do |url| Nokogiri::HTML(get(url)) end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/wagon/page.rb', line 22 def method_missing(method, *args, &block) unless source.respond_to?(method) super(method, *args, &block) else source.send(method, *args, &block) end end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
5 6 7 |
# File 'lib/wagon/page.rb', line 5 def connection @connection end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
5 6 7 |
# File 'lib/wagon/page.rb', line 5 def source @source end |
Instance Method Details
#get(*args) ⇒ Object
14 15 16 |
# File 'lib/wagon/page.rb', line 14 def get(*args) connection.get(*args) end |
#post(*args) ⇒ Object
18 19 20 |
# File 'lib/wagon/page.rb', line 18 def post(*args) connection.post(*args) end |