Class: Mechanize::Page::Image

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node, page) ⇒ Image

Returns a new instance of Image.



7
8
9
10
# File 'lib/mechanize/page/image.rb', line 7

def initialize(node, page)
  @node = node
  @page = page
end

Instance Attribute Details

#nodeObject (readonly)

Returns the value of attribute node.



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

def node
  @node
end

#pageObject (readonly)

Returns the value of attribute page.



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

def page
  @page
end

Instance Method Details

#srcObject



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

def src
  @node['src']
end

#urlObject



16
17
18
19
20
21
22
23
# File 'lib/mechanize/page/image.rb', line 16

def url
  case src
  when %r{^https?://}
    src
  else
    (page.uri + src).to_s
  end
end