lib/celerity/elements/table.rb in celerity-0.0.6 vs lib/celerity/elements/table.rb in celerity-0.0.7

- old
+ new

@@ -19,35 +19,37 @@ row.getCells.each do |c| @cells << c end end end + + @object end - + # # @return [Celerity::TableRows] # - + def rows assert_exists TableRows.new(self, :object, @rows) end - + # # @return [Celerity::TableCells] # - + def cells assert_exists TableCells.new(self, :object, @cells) end - + # # Iterates through each row in the table. # @yieldparam [Celerity::TableRow] row A row. # - + def each assert_exists @rows.each { |row| yield TableRow.new(self, :object, row) } end @@ -59,19 +61,19 @@ # # @param [Fixnum] index The index of the wanted row, 1-indexed. # @raise [Celerity::Exception::UnknownRowException] # @return [Celerity::TableRow] # - + def child_row(index) assert_exists - if (index - INDEX_OFFSET) >= @rows.length + if (index - Celerity.index_offset) >= @rows.length raise UnknownRowException, "Unable to locate a row at index #{index}" end - TableRow.new(self, :object, @rows[index - INDEX_OFFSET]) + TableRow.new(self, :object, @rows[index - Celerity.index_offset]) end alias_method :[], :child_row # # Returns the TableCell at the given index (1-indexed). @@ -80,46 +82,47 @@ # # @param [Fixnum] index The index of the wanted cell, 1-indexed. # @raise [Celerity::Exception::UnknownCellException] # @return [Celerity::TableCell] # - + def child_cell(index) assert_exists - if (index - INDEX_OFFSET) >= @cells.length + if (index - Celerity.index_offset) >= @cells.length raise UnknownCellException, "Unable to locate a cell at index #{index}" end - TableCell.new(self, :object, @cells[index - INDEX_OFFSET]) + + TableCell.new(self, :object, @cells[index - Celerity.index_offset]) end # # The number of rows in the table # @return [Fixnum] # - + def row_count assert_exists @object.getRowCount end - + # # Returns the number of columns on the row at the given index. (1-indexed) # Default is the number of columns on the first row # @param [Fixnum] index An index, 1-indexed (optional). # @return [Fixnum] # - - def column_count(index = INDEX_OFFSET) + + def column_count(index = Celerity.index_offset) assert_exists - @object.getRow(index - INDEX_OFFSET).getCells.length + @object.getRow(index - Celerity.index_offset).getCells.length end # # Returns the text of each cell in the the table as a two-dimensional array. # @return [Array<Array<String>>] # - + def to_a assert_exists # @object.getRows.map do |table_row| # table_row.getCells.map { |td| td.asText.strip } # end \ No newline at end of file