Class: Heidi::Build::Logs
- Inherits:
-
Object
- Object
- Heidi::Build::Logs
- Defined in:
- lib/heidi/build.rb
Defined Under Namespace
Classes: Log
Instance Method Summary collapse
- #[](key) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(log_root) ⇒ Logs
constructor
A new instance of Logs.
Constructor Details
#initialize(log_root) ⇒ Logs
Returns a new instance of Logs.
191 192 193 194 195 196 197 198 199 200 |
# File 'lib/heidi/build.rb', line 191 def initialize(log_root) @log_root = log_root @logs = [] FileUtils.mkdir_p log_root if !File.directory?(log_root) Dir[File.join(@log_root, "*")].each do |file| @logs << Log.new(file) end end |
Instance Method Details
#[](key) ⇒ Object
202 203 204 205 206 207 208 209 |
# File 'lib/heidi/build.rb', line 202 def [](key) log = @logs.select { |log| log.file_name == "#{key}" }.first if log.nil? @logs << ( log = Log.new( File.join(@log_root, "#{key}") ) ) end return log end |
#each(&block) ⇒ Object
211 212 213 214 |
# File 'lib/heidi/build.rb', line 211 def each(&block) heidi = @logs.select { |l| l.file_name =~ /heidi/ } (heidi + (@logs - heidi)).each(&block) end |