Sha256: 29c92cf474c399ef02ea3c406ffbbd9b21a33fbc10ff7cc7bd54e6f1416421a7

Contents?: true

Size: 939 Bytes

Versions: 4

Compression:

Stored size: 939 Bytes

Contents

module PageObject
  module Elements
    class OrderedList < 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 ordered list
      #
      def items
        list_items.size
      end

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

    ::PageObject::Elements.tag_to_class[:ol] = ::PageObject::Elements::OrderedList
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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