Class: Hyalite::DOM::Collection

Inherits:
Object
  • Object
show all
Includes:
Enumerable, Native
Defined in:
lib/hyalite/dom/collection.rb

Instance Method Summary collapse

Instance Method Details

#[](index) ⇒ Object



16
17
18
# File 'lib/hyalite/dom/collection.rb', line 16

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

#each(&block) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/hyalite/dom/collection.rb', line 8

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

  nil
end

#lengthObject



20
21
22
# File 'lib/hyalite/dom/collection.rb', line 20

def length
  `self.native.length`
end