Class: RubyPipeline::RemoteFile

Inherits:
Object
  • Object
show all
Includes:
DRbUndumped
Defined in:
lib/remote_file.rb

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ RemoteFile

Returns a new instance of RemoteFile.



10
11
12
# File 'lib/remote_file.rb', line 10

def initialize(filename)
  @filename = filename
end

Instance Method Details

#filenameObject

we flatten the filesystem out, maybe we shouldnt



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

def filename
  File.basename(@filename)
end

#get(buf_size = 8192) ⇒ Object

returns the bytes of the file, buf_size at a time. dave, thanks for the buffer size suggestion; that just about quadrupled performance



21
22
23
24
25
26
27
# File 'lib/remote_file.rb', line 21

def get(buf_size=8192)
  File.open(@filename) do |f|
    while buf = f.read(buf_size)
      yield buf
    end
  end
end