class TFTP::ReadOnlyFileServer

Public Class Methods

get(addr, port, filename, &block) click to toggle source
# 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| ... } click to toggle source
# File lib/em-tftp.rb, line 414
def self.put(addr, port, filename)
  yield false
end

Public Instance Methods

completed() click to toggle source
# File lib/em-tftp.rb, line 418
def completed
  # log?
end
failed(error_msg) click to toggle source
# File lib/em-tftp.rb, line 421
def failed(error_msg)
  # log?
end

Private Instance Methods

base_dir() click to toggle source
# File lib/em-tftp.rb, line 427
def base_dir
  self.class.instance_eval { @base_dir }
end