Class: Heidi::Build::Logs::Log

Inherits:
Object
  • Object
show all
Defined in:
lib/heidi/build.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Log

Returns a new instance of Log.



194
195
196
197
198
# File 'lib/heidi/build.rb', line 194

def initialize(file)
  @file      = file
  @file_name = File.basename(file)
  @contents  = File.read(file) rescue ""
end

Instance Attribute Details

#contentsObject (readonly)

Returns the value of attribute contents.



193
194
195
# File 'lib/heidi/build.rb', line 193

def contents
  @contents
end

#file_nameObject (readonly)

Returns the value of attribute file_name.



193
194
195
# File 'lib/heidi/build.rb', line 193

def file_name
  @file_name
end

Instance Method Details

#raw(msg) ⇒ Object



210
211
212
# File 'lib/heidi/build.rb', line 210

def raw(msg)
  write(msg, false)
end

#write(msg, fmt = true) ⇒ Object



200
201
202
203
204
205
206
207
208
# File 'lib/heidi/build.rb', line 200

def write(msg,fmt=true)
  File.open(@file, File::CREAT|File::APPEND|File::WRONLY) do |f|
    if fmt == true
      f.puts "%s\t%s" % [ Time.now.strftime("%c"), msg ]
    else
      f.puts msg
    end
  end
end