Class: Avaya::TFTP

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ TFTP

Returns a new instance of TFTP.



7
8
9
10
11
12
13
# File 'lib/avaya/tftp.rb', line 7

def initialize (file)
  tftp      = Net::TFTP.new(Avaya::Configuration.host)
  temp_file = Tempfile.new(random_file)
  tftp.getbinaryfile(file, temp_file)
  @file_data = temp_file.read
  temp_file.close # close instead of unlink to prevent rails for breaking
end

Class Method Details

.read(file, var2 = nil) ⇒ Object



15
16
17
18
# File 'lib/avaya/tftp.rb', line 15

def self.read(file, var2=nil)
  tftp = self.new Avaya.endpoint(file, var2)
  tftp.file_data
end

Instance Method Details

#file_dataObject



20
21
22
# File 'lib/avaya/tftp.rb', line 20

def file_data
  @file_data.split("\r\n")
end

#random_fileObject



24
25
26
# File 'lib/avaya/tftp.rb', line 24

def random_file
  (0...25).map { ('a'..'z').to_a[rand(26)] }.join
end