Class: Mechanize::Page::Image

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

Overview

An image element on an HTML page

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nodeObject (readonly)

Returns the value of attribute node.



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

def node
  @node
end

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

#srcObject



13
14
15
# File 'lib/mechanize/page/image.rb', line 13

def src
  @node['src']
end

#urlObject



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