class Nito::Cat

Public Class Methods

new(conf, string) click to toggle source
# File lib/nito/cat.rb, line 3
def initialize(conf, string)
  @conf = conf
  @string = string
  write_file
end

Private Instance Methods

write_file() click to toggle source
# File lib/nito/cat.rb, line 10
def write_file
  tmp = Tempfile.new(@conf)
  if File.exist? @conf
    File.open(@conf).each { |l|
      File.write(tmp, l, mode: 'a')
    }
  end
  File.write(tmp, @string, mode: 'a')
  Nito::Cp.new(tmp.path, @conf)
end