Sha256: 2e92534e5ba54ecf075dd60861592d2a6166320859ee4ebb78012cb2deddae6d

Contents?: true

Size: 881 Bytes

Versions: 19

Compression:

Stored size: 881 Bytes

Contents

module Watir
  module List
    include Enumerable

    #
    # Yields each LI associated with this list.
    #
    # @example
    #   list = browser.ol
    #   list.each do |li|
    #     puts li.text
    #   end
    #
    # @yieldparam [Watir::LI] element Iterate through the items for this List.
    #

    def each(&block)
      list_items.each(&block)
    end

    alias_method :length, :count
    alias_method :size, :count
    alias_method :items, :count
    alias_method :empty?, :none?

    #
    # Returns item from this list at given index.
    #
    # @param [Integer] idx
    # @return Watir::LI
    #

    def [](idx)
      list_items[idx]
    end

    def list_items
      LICollection.new(self, adjacent: :child, tag_name: 'li')
    end
  end # List

  class OList < HTMLElement
    include List
  end

  class UList < HTMLElement
    include List
  end
end # Watir

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
watir-6.13.0 lib/watir/elements/list.rb
watir-6.12.0 lib/watir/elements/list.rb
watir-6.11.0 lib/watir/elements/list.rb
watir-6.11.0.beta2 lib/watir/elements/list.rb
watir-6.11.0.beta1 lib/watir/elements/list.rb
watir-6.10.3 lib/watir/elements/list.rb
watir-6.10.2 lib/watir/elements/list.rb
watir-6.10.0 lib/watir/elements/list.rb
watir-6.9.1 lib/watir/elements/list.rb
watir-6.9.0 lib/watir/elements/list.rb
watir-6.8.4 lib/watir/elements/list.rb
watir-6.8.3 lib/watir/elements/list.rb
watir-6.8.2 lib/watir/elements/list.rb
watir-6.8.1 lib/watir/elements/list.rb
watir-6.8.0 lib/watir/elements/list.rb
watir-6.7.3 lib/watir/elements/list.rb
watir-6.7.2 lib/watir/elements/list.rb
watir-6.7.1 lib/watir/elements/list.rb
watir-6.7.0 lib/watir/elements/list.rb