Class: Achoo::Binary::UTMPRecord
- Inherits:
-
CStruct
- Object
- CStruct
- Achoo::Binary::UTMPRecord
show all
- Defined in:
- lib/achoo/binary/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
51
52
53
|
# File 'lib/achoo/binary/utmp_record.rb', line 51
def boot_event?
record_type_symbol == :boot
end
|
#halt_event? ⇒ Boolean
55
56
57
|
# File 'lib/achoo/binary/utmp_record.rb', line 55
def halt_event?
record_type_symbol == :term && device_name == ':0'
end
|
#record_type_symbol ⇒ Object
39
40
41
|
# File 'lib/achoo/binary/utmp_record.rb', line 39
def record_type_symbol
TYPE_MAP[record_type]
end
|
#record_type_symbol=(sym) ⇒ Object
43
44
45
|
# File 'lib/achoo/binary/utmp_record.rb', line 43
def record_type_symbol=(sym)
@values[0] = (TYPE_MAP.find_index(sym))
end
|
#time ⇒ Object
34
35
36
37
|
# File 'lib/achoo/binary/utmp_record.rb', line 34
def time
return nil if seconds.nil?
@time ||= Time.at(seconds, milliseconds)
end
|
#to_s ⇒ Object
47
48
49
|
# File 'lib/achoo/binary/utmp_record.rb', line 47
def to_s
sprintf "%s %-7s %-8s %s", time.strftime('%F_%T'), record_type_symbol, username, device_name
end
|