Module: Rreplay::Format

Defined in:
lib/rreplay/format.rb

Defined Under Namespace

Classes: Format

Constant Summary collapse

Json =
Format.new('.json',
->(str) { JSON.dump(str) },
->(str) { JSON.parse(str) },
false,
)
Msgpack =
Format.new('.msgpack',
->(str) { MessagePack.pack(str) },
->(str) { MessagePack.unpack(str) },
true,
)

Class Method Summary collapse

Class Method Details

.of(format) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/rreplay/format.rb', line 17

def of(format)
  case format.to_sym
  when :json
    Json
  when :msgpack
    Msgpack
  else
    raise "Unknown format #{format}"
  end
end