Class: Mechanize::Page::Image
- Inherits:
-
Object
- Object
- Mechanize::Page::Image
- Defined in:
- lib/mechanize/page/image.rb
Overview
An image element on an HTML page
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
Instance Method Summary collapse
-
#initialize(node, page) ⇒ Image
constructor
A new instance of Image.
- #src ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(node, page) ⇒ Image
Returns a new instance of Image.
8 9 10 11 |
# File 'lib/mechanize/page/image.rb', line 8 def initialize(node, page) @node = node @page = page end |
Instance Attribute Details
#node ⇒ Object (readonly)
Returns the value of attribute node.
5 6 7 |
# File 'lib/mechanize/page/image.rb', line 5 def node @node end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
6 7 8 |
# File 'lib/mechanize/page/image.rb', line 6 def page @page end |
Instance Method Details
#src ⇒ Object
13 14 15 |
# File 'lib/mechanize/page/image.rb', line 13 def src @node['src'] end |
#url ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/mechanize/page/image.rb', line 17 def url case src when %r{^https?://} src else if page.bases[0] (page.bases[0].href + src).to_s else (page.uri + src).to_s end end end |