Sha256: ad69a88aaf6405990a6949245760cde59d435413ede0142c2a8ba7b5d76525e9
Contents?: true
Size: 1.24 KB
Versions: 3
Compression:
Stored size: 1.24 KB
Contents
module Rambling module Trie module Serializers # Serializer for Ruby marshal format (.marshal) files. class Marshal # Creates a new Marshal serializer. # @param [Serializer] serializer the serializer responsible to write to # and read from disk. def initialize serializer = nil @serializer = serializer || Rambling::Trie::Serializers::File.new end # Loads marshaled object from contents in filepath and deserializes it # into a {Node Node}. # @param [String] filepath the full path of the file to load the # marshaled object from. # @return [Node] The deserialized {Node Node}. def load filepath ::Marshal.load serializer.load filepath end # Serializes a {Node Node} and dumps it as a marshaled object into # filepath. # @param [Node] node the node to serialize # @param [String] filepath the full path of the file to dump the # marshaled object into. # @return [Numeric] number of bytes written to disk. def dump node, filepath serializer.dump ::Marshal.dump(node), filepath end private attr_reader :serializer end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rambling-trie-1.0.2 | lib/rambling/trie/serializers/marshal.rb |
rambling-trie-1.0.1 | lib/rambling/trie/serializers/marshal.rb |
rambling-trie-1.0.0 | lib/rambling/trie/serializers/marshal.rb |