Sha256: 42a62b8fd46ea798882c65b084a8d12bf1f9be26d2f396fe00acea0701d4a42c

Contents?: true

Size: 387 Bytes

Versions: 12

Compression:

Stored size: 387 Bytes

Contents

require_relative 'element'

module Hyalite::DOM
  class Collection
    include Native
    include Enumerable

    def each(&block)
      `self.native.length`.times do |i|
        block.call Element.new(`self.native.item(i)`)
      end

      nil
    end

    def [](index)
      Element.new(`self.native.item(index)`)
    end

    def length
      `self.native.length`
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
hyalite-0.3.0 lib/hyalite/dom/collection.rb
hyalite-0.2.8 lib/hyalite/dom/collection.rb
hyalite-0.2.7 lib/hyalite/dom/collection.rb
hyalite-0.2.6 lib/hyalite/dom/collection.rb
hyalite-0.2.5 lib/hyalite/dom/collection.rb
hyalite-0.2.4 lib/hyalite/dom/collection.rb
hyalite-0.2.3 lib/hyalite/dom/collection.rb
hyalite-0.2.2 lib/hyalite/dom/collection.rb
hyalite-0.2.1 lib/hyalite/dom/collection.rb
hyalite-0.2.0 lib/hyalite/dom/collection.rb
hyalite-0.1.1 client/hyalite/dom/collection.rb
hyalite-0.1.0 client/hyalite/dom/collection.rb