Class: Helpers::NewFile
- Inherits:
-
Object
- Object
- Helpers::NewFile
- Defined in:
- lib/amnesie/helpers.rb
Direct Known Subclasses
Instance Method Summary collapse
- #add ⇒ Object
-
#initialize(string, name, dest = "/tmp") ⇒ NewFile
constructor
A new instance of NewFile.
- #perm(user, perm) ⇒ Object
Constructor Details
#initialize(string, name, dest = "/tmp") ⇒ NewFile
Returns a new instance of NewFile.
23 24 25 26 27 |
# File 'lib/amnesie/helpers.rb', line 23 def initialize(string, name, dest = "/tmp") @string = string @name = name @dest = dest + "/" + @name end |
Instance Method Details
#add ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/amnesie/helpers.rb', line 29 def add @mv = Helpers::Exec.new("mv") tmp = Tempfile.new(@name) File.open(tmp.path, 'w') do |file| file.puts @string end @mv.run("#{tmp.path} #{@dest}") end |
#perm(user, perm) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/amnesie/helpers.rb', line 38 def perm(user, perm) chown = Helpers::Exec.new("chown") chmod = Helpers::Exec.new("chmod") chown.run("#{user}:#{user} #{@dest}") chmod.run("#{perm} #{@dest}") end |