Sha256: 20b9b17e75643dd2a1a796e3340cdfef670fe85660dd557dc720942741c62d24

Contents?: true

Size: 938 Bytes

Versions: 22

Compression:

Stored size: 938 Bytes

Contents

module Celerity
  class TableRow < Element
    include Enumerable
    include ClickableElement

    TAGS = [ Identifier.new('tr') ]
    DEFAULT_HOW = :id

    def locate
      super
      @cells = @object.getCells if @object
    end

    #
    # Yields each TableCell in this row to the given block.
    #

    def each
      assert_exists
      @cells.each { |cell| yield TableCell.new(self, :object, cell) }
    end

    #
    # Get the child cell at the given index
    #

    def child_cell(index)
      assert_exists

      if (index - Celerity.index_offset) >= @cells.length
        raise UnknownCellException, "Unable to locate a cell at index #{index}"
      end

      TableCell.new(self, :object, @cells[index - Celerity.index_offset])
    end
    alias_method :[], :child_cell

    #
    # Number of cells in this row.
    #

    def column_count
      assert_exists
      @cells.length
    end

  end # TableRow
end # Celerity

Version data entries

22 entries across 22 versions & 6 rubygems

Version Path
celerity-0.0.7.2 lib/celerity/elements/table_row.rb
celerity-0.0.7 lib/celerity/elements/table_row.rb