Class: Basefile::FileHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/basefile/file_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#fileinObject

Returns the value of attribute filein.



3
4
5
# File 'lib/basefile/file_handler.rb', line 3

def filein
  @filein
end

#fileoutObject

Returns the value of attribute fileout.



3
4
5
# File 'lib/basefile/file_handler.rb', line 3

def fileout
  @fileout
end

Instance Method Details

#decode_file(encoded_str) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/basefile/file_handler.rb', line 19

def decode_file(encoded_str)
  if @fileout == nil
    return false
  else
    File.open(@fileout, "wb") do |file|
      file.write(::Basefile::Base64Shim.decode(encoded_str))
    end
  end
end

#encode_fileObject



10
11
12
13
14
15
16
17
# File 'lib/basefile/file_handler.rb', line 10

def encode_file
  if @filein == nil
    return false
  else
    f = File.open(@filein)
    return ::Basefile::Base64Shim.encode(f.read)
  end
end

#initalize(filein, fileout) ⇒ Object



5
6
7
8
# File 'lib/basefile/file_handler.rb', line 5

def initalize(filein, fileout)
  @filein = filein || nil
  @fileout = fileout || nil
end