Sha256: e5818983934601a96deee4b08c0bfed76dcc0e3f7ca612f18bfb6003ae612c38

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 KB

Contents

module Symbiont
  module WebObjects
    
    class Table < WebObject
      
      # This method is used to return a TableRow object based on the index provided.
      # @return [Symbiont::WebObjects::TableRow]
      def [](index)
        Object::Symbiont::WebObjects::TableRow.new(@web_object[index])
      end
      
      # This method is an iterator that returns a TableRow object each time through
      # the loop.
      # @return [Symbiont::WebObjects::TableRow]
      def each
        for index in 1..self.rows do
          yield self[index - 1]
        end
      end
      
      # This method will return the number of rows in a table.
      def rows
        @web_object.wd.find_elements(:xpath, row_xpath).size
      end
      
      # Returns a reference to the first row web object of a table.
      # @return [Symbiont::WebObjects::TableRow]
      def first_row
        self[0]
      end
      
      # Returns a reference to the last row web object of a table.
      # @return [Symbiont::WebObjects::TableRow]
      def last_row
        self[-1]
      end
      
      protected
      
      def row_xpath
        ".//child::tr"
      end
      
    end # class: Table
    
  end # module: WebObjects
end # module: Symbiont

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
symbiont-0.1.1 lib/symbiont/web_objects/table.rb