Sha256: db97db7fb7e5553c4df47fde114e2d45155458f9cba926630b789ba9d4711a97

Contents?: true

Size: 946 Bytes

Versions: 4

Compression:

Stored size: 946 Bytes

Contents

module PageObject
  module Elements
    class UnorderedList < Element
      include Enumerable

      #
      # iterator that yields with a PageObject::Elements::ListItem
      #
      # @return [PageObject::Elements::ListItem]
      #
      def each(&block)
        list_items.each(&block)
      end

      #
      # Return the PageObject::Elements::ListItem for the index provided.  Index
      # is zero based.
      #
      # @return [PageObject::Elements::ListItem]
      #
      def [](idx)
        list_items[idx]
      end

      #
      # Return the number of items contained in the unordered list
      #
      def items
        list_items.size
      end

      #
      # Return Array of ListItem objects that are children of the UnorderedList
      #
      def list_items
        @list_items ||= children(tag_name: 'li')
      end
    end

    ::PageObject::Elements.tag_to_class[:ul] = ::PageObject::Elements::UnorderedList
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
page-object-2.2.6 lib/page-object/elements/unordered_list.rb
page-object-2.2.5 lib/page-object/elements/unordered_list.rb
page-object-2.2.4 lib/page-object/elements/unordered_list.rb
page-object-2.2.3 lib/page-object/elements/unordered_list.rb