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

#<=>, #__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, #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, how, what, parent_table = nil) ⇒ TableBody

Returns a new instance of TableBody.



219
220
221
222
223
224
225
# File 'lib/watir/table.rb', line 219

def initialize(container, how, what, parent_table=nil)
  set_container container
  @how = how
  @what = what
  @parent_table = parent_table
  super nil
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 specified row as a TableRow object



228
229
230
231
# File 'lib/watir/table.rb', line 228

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

#eachObject

iterates through all the rows in the table body



234
235
236
237
# File 'lib/watir/table.rb', line 234

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

#lengthObject

returns the number of rows in this table body.



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

def length
  return @rows.length
end

#locateObject



204
205
206
207
208
209
210
211
212
213
214
215
216
217
# File 'lib/watir/table.rb', line 204

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