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/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/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.1.1.1'
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) ⇒ Object
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.
94 95 96 97 |
# File 'lib/rambling/trie.rb', line 94 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.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/rambling/trie.rb', line 38 def create filepath = nil, reader = nil root = root_builder.call Rambling::Trie::Container.new root, compressor do |container| if filepath reader ||= readers.resolve filepath reader.each_word filepath do |word| container << word end end yield container if block_given? end end |
.dump(trie, filepath, serializer = nil) ⇒ Object
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.
84 85 86 87 |
# File 'lib/rambling/trie.rb', line 84 def dump trie, filepath, serializer = nil serializer ||= serializers.resolve filepath 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.
67 68 69 70 71 72 73 |
# File 'lib/rambling/trie.rb', line 67 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 |