add page class, and Page#links
parent
6f8e9f743b
commit
f0ac299bb3
|
@ -1,5 +1,6 @@
|
|||
require "./file"
|
||||
require "./utils/element_matcher"
|
||||
require "./page/link"
|
||||
|
||||
class MechanizeCr::Page < MechanizeCr::File
|
||||
include MechanzeCr::ElementMatcher
|
||||
|
@ -33,6 +34,14 @@ class MechanizeCr::Page < MechanizeCr::File
|
|||
end.to_a
|
||||
end
|
||||
|
||||
def links
|
||||
links = %w{a area}.map do |tag|
|
||||
css(tag).map do |node|
|
||||
PageContent::Link.new(node, @mech, self)
|
||||
end
|
||||
end.flatten
|
||||
end
|
||||
|
||||
# generate form_with, forms_with methods
|
||||
# ex) form_with({:name => "login_form"})
|
||||
# it detects form(s) which match conditions.
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
class MechanizeCr::PageContent::Link
|
||||
property node : Lexbor::Node
|
||||
property page : Page
|
||||
property mech : Mechanize
|
||||
|
||||
def initialize(node, mech, page)
|
||||
@node = node
|
||||
@page = page
|
||||
@mech = mech
|
||||
# @attributes = node
|
||||
# @href = node['href']
|
||||
# @text = nil
|
||||
# @uri = nil
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue