Class: Achoo::System::UTMPRecord
- Inherits:
-
CStruct
- Object
- CStruct
- Achoo::System::UTMPRecord
show all
- Defined in:
- lib/achoo/system/utmp_record.rb
Constant Summary
collapse
- TYPE_MAP =
[:empty,
:run_lvl,
:boot,
:new_time,
:old_time,
:init,
:login,
:normal,
:term,
:account,
]
Instance Method Summary
collapse
Methods inherited from CStruct
bin_size, char, inherited, #initialize, long, #pack, quad, short, string, #unpack
Instance Method Details
#boot_event? ⇒ Boolean
54
55
56
|
# File 'lib/achoo/system/utmp_record.rb', line 54
def boot_event?
record_type_symbol == :boot
end
|
#halt_event? ⇒ Boolean
58
59
60
|
# File 'lib/achoo/system/utmp_record.rb', line 58
def halt_event?
record_type_symbol == :run_lvl && username == 'shutdown'
end
|
#record_type_symbol ⇒ Object
42
43
44
|
# File 'lib/achoo/system/utmp_record.rb', line 42
def record_type_symbol
TYPE_MAP[record_type]
end
|
#record_type_symbol=(sym) ⇒ Object
46
47
48
|
# File 'lib/achoo/system/utmp_record.rb', line 46
def record_type_symbol=(sym)
@values[0] = (TYPE_MAP.find_index(sym))
end
|
#time ⇒ Object
37
38
39
40
|
# File 'lib/achoo/system/utmp_record.rb', line 37
def time
return nil if seconds.nil?
@time ||= Time.at(seconds, milliseconds)
end
|
#to_s ⇒ Object
50
51
52
|
# File 'lib/achoo/system/utmp_record.rb', line 50
def to_s
sprintf "%s %-7s %-8s %s", time.strftime('%F_%T'), record_type_symbol, username, device_name
end
|