Module: Rambling::Trie
- Defined in:
- lib/rambling/trie.rb,
lib/rambling/trie/nodes.rb,
lib/rambling/trie/readers.rb,
lib/rambling/trie/version.rb,
lib/rambling/trie/container.rb,
lib/rambling/trie/nodes/raw.rb,
lib/rambling/trie/comparable.rb,
lib/rambling/trie/compressor.rb,
lib/rambling/trie/enumerable.rb,
lib/rambling/trie/nodes/node.rb,
lib/rambling/trie/inspectable.rb,
lib/rambling/trie/serializers.rb,
lib/rambling/trie/compressible.rb,
lib/rambling/trie/configuration.rb,
lib/rambling/trie/nodes/missing.rb,
lib/rambling/trie/stringifyable.rb,
lib/rambling/trie/readers/reader.rb,
lib/rambling/trie/serializers/zip.rb,
lib/rambling/trie/nodes/compressed.rb,
lib/rambling/trie/serializers/file.rb,
lib/rambling/trie/serializers/yaml.rb,
lib/rambling/trie/invalid_operation.rb,
lib/rambling/trie/readers/plain_text.rb,
lib/rambling/trie/serializers/marshal.rb,
lib/rambling/trie/serializers/serializer.rb,
lib/rambling/trie/configuration/properties.rb,
lib/rambling/trie/configuration/provider_collection.rb
Overview
Entry point for rambling-trie
API.
Defined Under Namespace
Modules: Comparable, Compressible, Configuration, Enumerable, Inspectable, Nodes, Readers, Serializers, Stringifyable Classes: Compressor, Container, InvalidOperation
Constant Summary collapse
- VERSION =
Current version of the rambling-trie.
'2.4.0'
Class Method Summary collapse
-
.config {|Configuration::Properties| ... } ⇒ Configuration::Properties
Provides configuration properties for the
Rambling::Trie
gem. -
.create(filepath = nil, reader = nil) {|Container| ... } ⇒ Container
Creates a new
Rambling::Trie
. -
.dump(trie, filepath, serializer = nil) ⇒ void
Dumps an existing trie from memory into disk.
-
.load(filepath, serializer = nil) {|Container| ... } ⇒ Container
Loads an existing trie from disk into memory.
Class Method Details
.config {|Configuration::Properties| ... } ⇒ Configuration::Properties
Provides configuration properties for the Rambling::Trie
gem.
75 76 77 78 |
# File 'lib/rambling/trie.rb', line 75 def config yield properties if block_given? properties end |
.create(filepath = nil, reader = nil) {|Container| ... } ⇒ Container
Creates a new Rambling::Trie
. Entry point for the rambling-trie
API.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rambling/trie.rb', line 21 def create filepath = nil, reader = nil root = root_builder.call Rambling::Trie::Container.new root, compressor do |container| # noinspection RubyMismatchedArgumentType if filepath reader ||= readers.resolve filepath # noinspection RubyMismatchedArgumentType,RubyNilAnalysis reader.each_word filepath do |word| container << word end end yield container if block_given? end end |
.dump(trie, filepath, serializer = nil) ⇒ void
This method returns an undefined value.
Dumps an existing trie from memory into disk. By default, it will deduce the correct way to serialize based on the file extension. Available formats are yml
, marshal
, and zip
versions of all the previous formats. You can also define your own.
66 67 68 69 70 |
# File 'lib/rambling/trie.rb', line 66 def dump trie, filepath, serializer = nil serializer ||= serializers.resolve filepath # noinspection RubyNilAnalysis serializer.dump trie.root, filepath end |
.load(filepath, serializer = nil) {|Container| ... } ⇒ Container
Use of # Marshal.load is generally discouraged. Only use the .marshal
format with trusted input.
Loads an existing trie from disk into memory. By default, it will deduce the correct way to deserialize based on the file extension. Available formats are yml
, marshal
, and zip
versions of all the previous formats. You can also define your own.
49 50 51 52 53 54 55 |
# File 'lib/rambling/trie.rb', line 49 def load filepath, serializer = nil serializer ||= serializers.resolve filepath root = serializer.load filepath Rambling::Trie::Container.new root, compressor do |container| yield container if block_given? end end |