Completed
Push — master ( 2c8d61...d12e3c )
by Yoh
48s
created

Collection.length()   A

Complexity

Conditions 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
1
require_relative 'element'
2
3
module Hyalite::DOM
4
  class Collection
5
    include Native
6
    include Enumerable
7
8
    def each(&block)
9
      `self.native.length`.times do |i|
10
        block.call Element.new(`self.native.item(i)`)
11
      end
12
13
      nil
14
    end
15
16
    def [](index)
17
      Element.new(`self.native.item(index)`)
18
    end
19
20
    def length
21
      `self.native.length`
22
    end
23
  end
24
end
25