class ChangePerms
Public Class Methods
new(perms,type,file)
click to toggle source
# File lib/simple-chmod/perms.rb, line 5 def initialize(perms,type,file) @perms = perms @type = type @file = file end
Public Instance Methods
result()
click to toggle source
# File lib/simple-chmod/perms.rb, line 11 def result if @perms == 'none' shell_script_output = `chmod #{@type}-rwx #{@file}` print "Changed permissions.\n" elsif @perms == 'read write' || @perms == 'read xcute' || @perms == 'write read' || @perms == 'write xcute' || @perms == 'xcute read' || @perms == 'xcute write' || @perms == 'read' || @perms == 'write' || @perms == 'xcute' ||@perms == 'read write xcute' replaceperms = @perms.gsub("read", "r").gsub("write", "w").gsub("xcute", "x") finalperms = replaceperms.delete("\s") shell_script_output = `chmod #{@type}-rwx #{@file}` shell_script_output = `chmod #{@type}+#{finalperms} #{@file}` print "Changed permissions.\n" else print "No valid file permissions.\n" end end