Class: Heidi::Build::Logs::Log
- Inherits:
-
Object
- Object
- Heidi::Build::Logs::Log
- Defined in:
- lib/heidi/build.rb
Instance Attribute Summary collapse
-
#contents ⇒ Object
readonly
Returns the value of attribute contents.
-
#file_name ⇒ Object
readonly
Returns the value of attribute file_name.
Instance Method Summary collapse
-
#initialize(file) ⇒ Log
constructor
A new instance of Log.
- #raw(msg) ⇒ Object
- #read ⇒ Object
- #write(msg, fmt = true) ⇒ Object
Constructor Details
#initialize(file) ⇒ Log
Returns a new instance of Log.
218 219 220 221 222 |
# File 'lib/heidi/build.rb', line 218 def initialize(file) @file = file @file_name = File.basename(file) @contents = File.read(file) rescue "" end |
Instance Attribute Details
#contents ⇒ Object (readonly)
Returns the value of attribute contents.
217 218 219 |
# File 'lib/heidi/build.rb', line 217 def contents @contents end |
#file_name ⇒ Object (readonly)
Returns the value of attribute file_name.
217 218 219 |
# File 'lib/heidi/build.rb', line 217 def file_name @file_name end |
Instance Method Details
#raw(msg) ⇒ Object
242 243 244 |
# File 'lib/heidi/build.rb', line 242 def raw(msg) write(msg, false) end |
#read ⇒ Object
236 237 238 239 240 |
# File 'lib/heidi/build.rb', line 236 def read @contents = File.read(@file) rescue @contents = "" end |
#write(msg, fmt = true) ⇒ Object
224 225 226 227 228 229 230 231 232 233 234 |
# File 'lib/heidi/build.rb', line 224 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 read end |