Class: Watir::TableBodies

Inherits:
Element
  • Object
show all
Defined in:
lib/watir/table.rb

Overview

this class is a collection of the table body objects that exist in the table it wouldnt normally be created by a user, but gets returned by the bodies method of the Table object many of the methods available to this object are inherited from the Element class

Constant Summary

Constants inherited from Element

Element::TO_S_SIZE

Instance Attribute Summary

Attributes inherited from Element

#container

Attributes included from Container

#activeObjectHighLightColor, #page_container, #type_keys, #typingspeed

Instance Method Summary collapse

Methods inherited from Element

#<=>, #__ole_inner_elements, #activeObjectHighLightColor, #after_text, #assert_enabled, #assert_exists, #attribute_value, #before_text, #click, #click!, #create_event, #dispatch_event, #document, #enabled?, #exists?, #fire_event, #flash, #focus, inherited, #inspect, #locate, #method_missing, #name, #ole_object, #ole_object=, #parent, #text, #to_s, #type_keys, #typingspeed, #visible?

Methods included from Container

#__ole_inner_elements, #input_element_locator, #locator_for, #log, #set_container, #show_all_objects, #tagged_element_locator, #wait

Constructor Details

#initialize(container, parent_table) ⇒ TableBodies

Returns a new instance of TableBodies.



171
172
173
174
# File 'lib/watir/table.rb', line 171

def initialize(container, parent_table)
  set_container container
  @o = parent_table     # in this case, @o is the parent table

end

Dynamic Method Handling

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

Instance Method Details

#[](n) ⇒ Object

returns the n’th Body as a Watir TableBody object



183
184
185
186
# File 'lib/watir/table.rb', line 183

def []n
  assert_exists
  return TableBody.new(@container, :ole_object, ole_table_body_at_index(n))
end

#eachObject

iterates through each of the TableBodies in the Table. Yields a TableBody object



194
195
196
197
198
# File 'lib/watir/table.rb', line 194

def each
  0.upto(@o.tBodies.length - 1) do |i| 
    yield TableBody.new(@container, :ole_object, ole_table_body_at_index(i))
  end
end

#lengthObject

returns the number of TableBodies that exist in the table



177
178
179
180
# File 'lib/watir/table.rb', line 177

def length
  assert_exists
  return @o.tBodies.length
end

#ole_table_body_at_index(n) ⇒ Object

returns an ole table body



189
190
191
# File 'lib/watir/table.rb', line 189

def ole_table_body_at_index(n)
  return @o.tBodies.item(n)
end