Sha256: 8dc2ff9dff0283ed0cf12d0b2f59d893404dc6adb84c9dc7f621e65a7a872c0b

Contents?: true

Size: 847 Bytes

Versions: 2

Compression:

Stored size: 847 Bytes

Contents

module Druid
  module Elements
    class UnOrderedList < Element

      def self.finders
        [:class, :id, :index, :xpath]
      end

      def [](idx)
        Druid::Elements::ListItem.new(children[idx])
      end

      def items
        children.size
      end

      def each
        for index in 1..self.items do
          yield self[index-1]
        end
      end

      #
      # return the ListItem objects that are children of the
      # UnOrderedList
      #
      def list_items
        children.collect do |obj|
          Druid::Elements::ListItem.new(obj)
        end
      end

      protected

      def child_xpath
        "./child::li"
      end

      private

      def children
        element.uls(:xpath => child_xpath)
      end
    end

    Druid::Elements.tag_to_class[:ul] = Druid::Elements::UnOrderedList

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
druid-ts-1.2.2 lib/druid/elements/unordered_list.rb
druid-ts-1.2.1 lib/druid/elements/unordered_list.rb