Class: Wagon::Page

Inherits:
Object
  • Object
show all
Defined in:
lib/wagon/page.rb

Direct Known Subclasses

Directory, Ward

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#connectionObject (readonly)

Returns the value of attribute connection.



5
6
7
# File 'lib/wagon/page.rb', line 5

def connection
  @connection
end

#sourceObject (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