Class: Achoo::System::PMSuspend

Inherits:
Array
  • Object
show all
Defined in:
lib/achoo/system/pm_suspend.rb

Defined Under Namespace

Classes: LogEntry

Instance Method Summary collapse

Constructor Details

#initialize(glob = '/var/log/pm-suspend.log*') ⇒ PMSuspend

Returns a new instance of PMSuspend.



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/achoo/system/pm_suspend.rb', line 16

def initialize(glob='/var/log/pm-suspend.log*')
  super()
  Dir.glob(glob).sort.reverse.each do |file|
    next if file =~ /\.gz$/ # FIX uncompress?
    File.open(file, 'r') do |fh|
      fh.readlines.each do |l|
        l.chop!
        next unless l =~ /Awake|performing suspend/
        self << LogEntry.new(*l.split(': '))
      end
    end
  end
end