Sha256: 296df56bdb11c766544685ae14faa4afd072128299afbf7d58a1bf480a24a438

Contents?: true

Size: 748 Bytes

Versions: 8

Compression:

Stored size: 748 Bytes

Contents

module Druid
  module Elements
    class OrderedList < Element
      attr_accessor :li_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

      protected

      def child_xpath
        ".//child::li"
      end

      private

      def children
        list_items.find_all { |item| item.parent == element }
      end

      def list_items
        element.ols(:xpath => child_xpath)
      end

    end

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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
druid-ts-1.2.0 lib/druid/elements/ordered_list.rb
druid-ts-1.1.8 lib/druid/elements/ordered_list.rb
druid-ts-1.1.7 lib/druid/elements/ordered_list.rb
druid-ts-1.1.6 lib/druid/elements/ordered_list.rb
druid-ts-1.1.5 lib/druid/elements/ordered_list.rb
druid-ts-1.1.4 lib/druid/elements/ordered_list.rb
druid-ts-1.1.3 lib/druid/elements/ordered_list.rb
druid-ts-1.1.2 lib/druid/elements/ordered_list.rb