Class: Mechanize::Page::Label

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

Overview

A form label on an HTML page

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node, page) ⇒ Label

Returns a new instance of Label.



10
11
12
13
14
# File 'lib/mechanize/page/label.rb', line 10

def initialize(node, page)
  @node = node
  @text = node.inner_text
  @page = page
end

Instance Attribute Details

#nodeObject (readonly)

Returns the value of attribute node.



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

def node
  @node
end

#pageObject (readonly)

Returns the value of attribute page.



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

def page
  @page
end

#textObject (readonly) Also known as: to_s

Returns the value of attribute text.



6
7
8
# File 'lib/mechanize/page/label.rb', line 6

def text
  @text
end

Instance Method Details

#forObject



16
17
18
# File 'lib/mechanize/page/label.rb', line 16

def for
  (id = @node['for']) && page.search("##{id}") || nil
end