Class: Achoo::System::Wtmp
Instance Method Summary collapse
-
#initialize(glob = '/var/log/wtmp*') ⇒ Wtmp
constructor
A new instance of Wtmp.
- #to_s ⇒ Object
Methods inherited from Array
Constructor Details
#initialize(glob = '/var/log/wtmp*') ⇒ Wtmp
Returns a new instance of Wtmp.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/achoo/system/wtmp.rb', line 8 def initialize(glob='/var/log/wtmp*') super() chunk_size = UTMPRecord.bin_size Dir.glob(glob).sort.reverse.each do |file| File.open(file, 'r') do |io| while (bytes = io.read(chunk_size)) self << UTMPRecord.new(bytes) end end end end |
Instance Method Details
#to_s ⇒ Object
20 21 22 |
# File 'lib/achoo/system/wtmp.rb', line 20 def to_s inject('') {|str, e| str << e.to_s << "\n"} end |