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/not_implemented.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
:reek:IrresponsibleModule (unclear why this is necessary here but not in other submodules)
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.7.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.
72 73 74 75 |
# File 'lib/rambling/trie.rb', line 72 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.
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rambling/trie.rb', line 23 def create filepath = nil, reader = nil root = root_builder.call Rambling::Trie::Container.new root, compressor do |container| if filepath input_reader = reader || readers.resolve(filepath) || raise(ArgumentError, "no reader for #{filepath}") input_reader.each_word(filepath) { |word| container << word } end yield container if block_given? # steep:ignore 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.
64 65 66 67 |
# File 'lib/rambling/trie.rb', line 64 def dump trie, filepath, serializer = nil serializer ||= serializers.resolve filepath (serializer || raise).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.
47 48 49 50 51 52 53 |
# File 'lib/rambling/trie.rb', line 47 def load filepath, serializer = nil serializer ||= serializers.resolve filepath root = (serializer || raise).load filepath Rambling::Trie::Container.new root, compressor do |container| yield container if block_given? # steep:ignore end end |