Wrap text
|
|
#!/usr/bin/env ruby -wKU
class MoveFile
@@filename = ""
@@destination = ""
def initialize(filename, destination)
@filename = filename
@destination = destination
end
def checkleft
return `df -kl`.split(" ")[10]
end
def checksize
return `du -k #{@filename}`.split(" ")[0]
end
def enoughspace?
return (self.checksize < self.checkleft ? true : false)
end
def movefile
if self.enoughspace?
if system("mv #{@filename} #{@destination}")
print "Success!"
else
print "Failure!"
end
else
print "Not enough space!"
end
end
end
file = MoveFile::new($*[0], $*[1])
file.movefile
|