Class: RCS::CallListSerializer
- Inherits:
-
Object
- Object
- RCS::CallListSerializer
- Includes:
- Tracer
- Defined in:
- lib/rcs-common/serializer.rb
Constant Summary collapse
- TYPES =
{0x01 => :name, 0x02 => :type, 0x04 => :note, 0x08 => :number}
- INCOMING =
0x00
- OUTGOING =
0x01
Constants included from Tracer
Instance Attribute Summary collapse
-
#end_time ⇒ Object
readonly
Returns the value of attribute end_time.
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
-
#start_time ⇒ Object
readonly
Returns the value of attribute start_time.
Instance Method Summary collapse
-
#initialize ⇒ CallListSerializer
constructor
A new instance of CallListSerializer.
- #unserialize(stream) ⇒ Object
Methods included from Tracer
#thread_name, #trace, #trace_ensure_log_folders, #trace_init, #trace_named_put, #trace_named_remove, #trace_nested_pop, #trace_nested_push, #trace_setup
Constructor Details
#initialize ⇒ CallListSerializer
Returns a new instance of CallListSerializer.
94 95 96 97 98 99 |
# File 'lib/rcs-common/serializer.rb', line 94 def initialize @fields = {} @start_time = nil @end_time = nil @properties = [] end |
Instance Attribute Details
#end_time ⇒ Object (readonly)
Returns the value of attribute end_time.
92 93 94 |
# File 'lib/rcs-common/serializer.rb', line 92 def end_time @end_time end |
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
92 93 94 |
# File 'lib/rcs-common/serializer.rb', line 92 def fields @fields end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
92 93 94 |
# File 'lib/rcs-common/serializer.rb', line 92 def properties @properties end |
#start_time ⇒ Object (readonly)
Returns the value of attribute start_time.
92 93 94 |
# File 'lib/rcs-common/serializer.rb', line 92 def start_time @start_time end |
Instance Method Details
#unserialize(stream) ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/rcs-common/serializer.rb', line 101 def unserialize(stream) # HEADER header_begin = stream.pos tot_size = stream.read(4).unpack('L').shift version = stream.read(4).unpack('L').shift low, high = stream.read(8).unpack 'V2' @start_time = Time.from_filetime high, low low, high = stream.read(8).unpack 'V2' @end_time = Time.from_filetime high, low props = stream.read(4).unpack('L').shift if props & OUTGOING == 1 @properties << :outgoing else @properties << :incoming end # BODY header_length = stream.pos - header_begin content = stream.read(tot_size - header_length) until content.empty? prefix = content.slice!(0, 4) type, size = Serialization.decode_prefix prefix @fields[TYPES[type]] = content.slice!(0, size).utf16le_to_utf8 end self end |