forked from sparklemotion/mechanize
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Form::Image,Label and Form::RadioButton#text that traces its label
- Loading branch information
Showing
5 changed files
with
85 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
class Mechanize | ||
class Page < Mechanize::File | ||
class Image | ||
attr_reader :node | ||
attr_reader :page | ||
|
||
def initialize(node, page) | ||
@node = node | ||
@page = page | ||
end | ||
|
||
def src | ||
@node['src'] | ||
end | ||
|
||
def url | ||
case src | ||
when %r{^https?://} | ||
src | ||
else | ||
(page.uri + src).to_s | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
class Mechanize | ||
class Page < Mechanize::File | ||
class Label | ||
attr_reader :node | ||
attr_reader :text | ||
attr_reader :page | ||
alias :to_s :text | ||
|
||
def initialize(node, page) | ||
@node = node | ||
@text = node.inner_text | ||
@page = page | ||
end | ||
|
||
def for | ||
(id = @node['for']) && page.search("##{id}") || nil | ||
end | ||
end | ||
end | ||
end |