Sha256: 62d3ab182ff9e157d821b4d6d2686d2b1508ce49e885790741b4090ef844ecb4

Contents?: true

Size: 794 Bytes

Versions: 5

Compression:

Stored size: 794 Bytes

Contents

module Celerity
  class TableElement < Element
    include Enumerable

    ATTRIBUTES = BASE_ATTRIBUTES | CELLHALIGN_ATTRIBUTES | CELLVALIGN_ATTRIBUTES
    DEFAULT_HOW = :id

    def locate
      super
      @rows = @object.getRows if @object
    end

    def [](index)
      assert_exists
      TableRow.new(self, :object, @rows[index - INDEX_OFFSET])
    end

    def length
      assert_exists
      @object.getRows.length
    end

    def each
      assert_exists
      @rows.each { |row| yield TableRow.new(self, :object, row) }
    end
  end

  class TableBody < TableElement
    TAGS = [ Identifier.new('tbody') ]
  end

  class TableFooter < TableElement
    TAGS = [ Identifier.new('tfoot') ]
  end

  class TableHeader < TableElement
    TAGS = [ Identifier.new('thead') ]
  end

end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
hirobumi-celerity-0.0.5 lib/celerity/elements/table_elements.rb
jarib-celerity-0.0.5.1 lib/celerity/elements/table_elements.rb
jarib-celerity-0.0.5.2 lib/celerity/elements/table_elements.rb
jarib-celerity-0.0.5.4 lib/celerity/elements/table_elements.rb
jarib-celerity-0.0.5 lib/celerity/elements/table_elements.rb