Method: FileEdit#initialize

Defined in:
lib/chef/util/fileedit.rb

#initialize(filepath) ⇒ FileEdit

Returns a new instance of FileEdit.

Raises:

  • (ArgumentError)


30
31
32
33
34
35
36
# File 'lib/chef/util/fileedit.rb', line 30

def initialize(filepath)
  @original_pathname = filepath
  @file_edited = false
  
  raise ArgumentError, "File doesn't exist" unless File.exist? @original_pathname
  raise ArgumentError, "File is blank" unless (@contents = File.new(@original_pathname).readlines).length > 0
end