Sha256: 3bb40065c80ba23b27f39c8332551c896345699c43e4343f5b99176132d35cc5

Contents?: true

Size: 776 Bytes

Versions: 2

Compression:

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

      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.ols(:xpath => child_xpath)
      end

    end

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

Version data entries

2 entries across 2 versions & 1 rubygems

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