Class: Browser::FileList

Inherits:
Object show all
Includes:
Enumerable
Defined in:
lib/browser/file_list.rb

Defined Under Namespace

Classes: File

Instance Method Summary collapse

Constructor Details

#initialize(native) ⇒ FileList



6
7
8
9
10
11
# File 'lib/browser/file_list.rb', line 6

def initialize native
  @native = `#{native} || []`
  @files = length.times.each_with_object([]) { |index, array|
    array[index] = File.new(`#@native[index]`)
  }
end

Instance Method Details

#[](index) ⇒ Browser::FileList::File



15
16
17
# File 'lib/browser/file_list.rb', line 15

def [] index
  @files[index]
end

#each {|file| ... } ⇒ Object

Call the given block for each file in the list

Yield Parameters:



28
29
30
31
32
# File 'lib/browser/file_list.rb', line 28

def each &block
  @files.each do |file|
    block.call file
  end
end

#lengthInteger Also known as: size



20
21
22
# File 'lib/browser/file_list.rb', line 20

def length
  `#@native.length`
end

#to_aObject Also known as: to_ary

Convert this FileList into an array



35
36
37
# File 'lib/browser/file_list.rb', line 35

def to_a
  @files.dup # Don't return a value that can mutate our internal state
end

#to_sString



41
42
43
# File 'lib/browser/file_list.rb', line 41

def to_s
  @files.to_s
end