Class: TFTP::ReadOnlyFileServer

Inherits:
Object
  • Object
show all
Defined in:
lib/em-tftp.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.get(addr, port, filename, &block) ⇒ Object



400
401
402
403
404
405
406
407
408
409
410
411
412
# File 'lib/em-tftp.rb', line 400

def self.get(addr, port, filename, &block)
  filename.slice!(0) if filename.start_with?('/')
  begin
    path = File.join(@base_dir, filename)
    if File.exist?(path)
      EventMachine.defer(proc { File.binread(path) }, proc { |file_data| block.call(true, file_data) })
    else
      block.call(false, "File not found")
    end
  rescue
    block.call(false, $!.message)
  end
end

.put(addr, port, filename) {|false| ... } ⇒ Object

Yields:

  • (false)


414
415
416
# File 'lib/em-tftp.rb', line 414

def self.put(addr, port, filename)
  yield false
end

Instance Method Details

#completedObject



418
419
420
# File 'lib/em-tftp.rb', line 418

def completed
  # log?
end

#failed(error_msg) ⇒ Object

log?



421
422
423
# File 'lib/em-tftp.rb', line 421

def failed(error_msg)
  # log?
end