Sha256: 1c2f0250906548774a7106edb3a6bb932b27cdc07d8ad1431c9b922e7b75c5ab

Contents?: true

Size: 918 Bytes

Versions: 4

Compression:

Stored size: 918 Bytes

Contents

module Druid
  module Elements
    class Table < Element
      #
      # Return the Druid::Elements::Table for the index provided.  Index
      # is zero based.
      #
      # @return [Druid::Elements::Table]
      #
      def [](idx)
        table_row = element[idx]
        Druid::Elements::TableRow.new(table_row)
      end
      #
      # Returns the number of rows in the table.
      #
      def rows
        element.rows.size
      end

      def each
        for index in 1..self.rows do
          yield self[index-1]
        end
      end

      #
      # return the first row
      #
      # @return Druid::Elements::TableRow
      #
      def first_row
        self[0]
      end

      #
      # return the last row
      #
      # @return Druid::Elements::TableRow
      #
      def last_row
        self[-1]
      end

    end

    Druid::Elements.tag_to_class[:table] = Druid::Elements::Table
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
druid-ts-1.1.3 lib/druid/elements/table.rb
druid-ts-1.1.2 lib/druid/elements/table.rb
druid-ts-1.1.1 lib/druid/elements/table.rb
druid-ts-1.1.0 lib/druid/elements/table.rb