Class: Hyalite::DOM::Collection
- 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 |
#first ⇒ Object
20 21 22 |
# File 'lib/hyalite/dom/collection.rb', line 20 def first Element.new(`self.native.item(0)`) end |
#last ⇒ Object
24 25 26 |
# File 'lib/hyalite/dom/collection.rb', line 24 def last Element.new(`self.native.item(self.native.length - 1)`) end |
#length ⇒ Object
28 29 30 |
# File 'lib/hyalite/dom/collection.rb', line 28 def length `self.native.length` end |