Class: Watir::TableBody

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

Overview

this class is a table body

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

#<=>, #activeObjectHighLightColor, #after_text, #assert_enabled, #assert_exists, #attribute_value, #before_text, #click, #click!, #click_no_wait, #document, #enabled?, #exists?, #fire_event, #flash, #focus, #inspect, #ole_object, #ole_object=, #parent, #text, #to_s, #type_keys, #typingspeed, #visible?

Methods included from Container

#area, #areas, #button, #buttons, #cell, #cells, #checkbox, #checkboxes, #dds, #divs, #dls, #dts, #element, #elements, #ems, #file_field, #file_fields, #form, #forms, #frame, #hidden, #hiddens, #image, #images, #labels, #link, #links, #lis, #locate_all_elements, #locate_input_element, #locate_tagged_element, #log, #map, #maps, #modal_dialog, #popup, #pres, #ps, #radio, #radios, #row, #rows, #select_list, #select_lists, #set_container, #show_all_objects, #spans, #strongs, #table, #tables, #text_field, #text_fields, #wait

Constructor Details

#initialize(container, how, what, parent_table = nil) ⇒ TableBody

Returns a new instance of TableBody.



229
230
231
232
233
234
235
# File 'lib/watir/table.rb', line 229

def initialize(container, how, what, parent_table=nil)
  set_container container
  @how = how
  @what = what
  @parent_table = parent_table
  super nil
end

Instance Method Details

#[](n) ⇒ Object

returns the specified row as a TableRow object



238
239
240
241
# File 'lib/watir/table.rb', line 238

def [](n)
  assert_exists
  return @rows[n - 1]
end

#eachObject

iterates through all the rows in the table body



244
245
246
247
# File 'lib/watir/table.rb', line 244

def each
  locate
  0.upto(@rows.length - 1) { |i| yield @rows[i] }
end

#lengthObject

returns the number of rows in this table body.



250
251
252
# File 'lib/watir/table.rb', line 250

def length
  return @rows.length
end

#locateObject



214
215
216
217
218
219
220
221
222
223
224
225
226
227
# File 'lib/watir/table.rb', line 214

def locate
  @o = nil
  if @how == :ole_object
    @o = @what     # in this case, @o is the table body
  elsif @how == :index
    @o = @parent_table.bodies.ole_table_body_at_index(@what)
  end
  @rows = []
  if @o
    @o.rows.each do |oo|
      @rows << TableRow.new(@container, :ole_object, oo)
    end
  end
end