Sha256: 4be4d6a3222008e0da958f38f8578dd5a677b51a85e9be348ec51e9144303bba

Contents?: true

Size: 982 Bytes

Versions: 3

Compression:

Stored size: 982 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

3 entries across 3 versions & 2 rubygems

Version Path
centric_page_object-2.3.1 lib/page-object/elements/ordered_list.rb
page-object-2.3.1 lib/page-object/elements/ordered_list.rb
page-object-2.3.0 lib/page-object/elements/ordered_list.rb