Class: Webrat::CheckboxField

Inherits:
Field show all
Defined in:
lib/webrat/core/elements/field.rb

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from Field

#value

Attributes inherited from Element

#element

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Field

#disabled?, field_class, field_classes, #id, inherited, #initialize, #label_text, load, #name, #raise_error_if_disabled, #set, #to_multipart_param, #unset

Methods inherited from Element

#initialize, #inspect, load, load_all, #path

Constructor Details

This class inherits a constructor from Webrat::Field

Class Method Details

.xpath_searchObject



235
236
237
# File 'lib/webrat/core/elements/field.rb', line 235

def self.xpath_search
  ".//input[@type = 'checkbox']"
end

Instance Method Details

#checkObject



244
245
246
247
# File 'lib/webrat/core/elements/field.rb', line 244

def check
  raise_error_if_disabled
  set(Webrat::XML.attribute(@element, "value") || "on")
end

#checked?Boolean

Returns:

  • (Boolean)


249
250
251
# File 'lib/webrat/core/elements/field.rb', line 249

def checked?
  Webrat::XML.attribute(@element, "checked") == "checked"
end

#to_paramObject



239
240
241
242
# File 'lib/webrat/core/elements/field.rb', line 239

def to_param
  return nil if @value.nil?
  super
end

#uncheckObject



253
254
255
256
# File 'lib/webrat/core/elements/field.rb', line 253

def uncheck
  raise_error_if_disabled
  set(nil)
end