Class: Celerity::CheckBox

Inherits:
RadioCheckCommon show all
Defined in:
lib/celerity/elements/radio_check.rb

Overview

This class is the representation of a check box.

Constant Summary collapse

TAGS =
Identifier.new('input', :type => %w[checkbox])

Constants inherited from RadioCheckCommon

RadioCheckCommon::DEFAULT_HOW

Constants inherited from InputElement

InputElement::ATTRIBUTES

Constants inherited from Element

Element::ATTRIBUTES, Element::BASE_ATTRIBUTES, Element::CELLHALIGN_ATTRIBUTES, Element::CELLVALIGN_ATTRIBUTES, Element::DEFAULT_HOW, Element::HTML_401_TRANSITIONAL, Element::TO_S_SIZE

Instance Attribute Summary

Attributes inherited from Element

#container

Attributes included from Container

#browser

Instance Method Summary collapse

Methods inherited from RadioCheckCommon

#clear, #getState, #get_state, #isSet?, #is_set?, #set?

Methods inherited from InputElement

#readonly?

Methods included from DisabledElement

#assert_enabled, #disabled?, #enabled?

Methods included from ClickableElement

#click, #click_and_attach, #double_click, #download, #right_click

Methods inherited from Element

#assert_exists, #attribute_string, #attribute_value, #exists?, #fire_event, #focus, #javascript_object, #locate, #method_missing, #methods, #object, #parent, #respond_to?, #text, #to_s, #to_xml, #visible?, #xpath

Methods included from Container

#area, #areas, #button, #buttons, #cell, #cells, #check_box, #checkboxes, #container=, #contains_text, #dd, #dds, #div, #divs, #dl, #dls, #dt, #dts, #em, #ems, #file_field, #file_fields, #form, #forms, #frame, #frames, #h1, #h1s, #h2, #h2s, #h3, #h3s, #h4, #h4s, #h5, #h5s, #h6, #h6s, #hidden, #hiddens, #image, #images, #inspect, #label, #labels, #li, #link, #links, #lis, #map, #maps, #meta, #metas, #ol, #ols, #option, #p, #pre, #pres, #ps, #radio, #radios, #row, #rows, #select_list, #select_lists, #span, #spans, #strong, #strongs, #table, #tables, #tbodies, #tbody, #text_field, #text_fields, #tfoot, #tfoots, #th, #thead, #theads, #ths, #ul, #uls

Methods included from ShortInspect

#short_inspect

Constructor Details

#initialize(container, *args) ⇒ CheckBox

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of CheckBox.



90
91
92
# File 'lib/celerity/elements/radio_check.rb', line 90

def initialize(container, *args)
  super(container, %w[checkbox], *args)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Celerity::Element

Instance Method Details

#set(value = true) ⇒ Object

Set the checkbox to the given value.

checkbox.set?         #=> false
checkbox.set
checkbox.set?         #=> true
checkbox.set(false)
checkbox.set?         #=> false


104
105
106
107
108
109
110
111
112
# File 'lib/celerity/elements/radio_check.rb', line 104

def set(value = true)
  assert_exists
  assert_enabled

  if (value && !set?) || (!value && set?)
    Log.debug(@object.inspect)
    @object.click
  end
end