class Rambling::Trie::Configuration::Properties

Provides configurable properties for Rambling::Trie.

Attributes

compressor[RW]

The configured {Compressor Compressor}. @return [Compressor] the configured compressor.

readers[RW]

The configured {Readers Readers}. @return [ProviderCollection<Readers::Reader>] the mapping of

configured {Readers Readers}.
root_builder[RW]

The configured root_builder, which returns a {Nodes::Node Node} when called. @return [Proc<Nodes::Node>] the configured root_builder.

serializers[RW]

The configured {Serializers Serializers}. @return [ProviderCollection<Serializers::Serializer>] the mapping of

configured {Serializers Serializers}.
tmp_path[RW]

The configured tmp_path, which will be used for throwaway files. @return [String] the configured tmp_path.

Public Class Methods

new() click to toggle source

Returns a new properties instance.

# File lib/rambling/trie/configuration/properties.rb, line 32
def initialize
  reset
end

Public Instance Methods

reset() click to toggle source

Resets back to default properties. @return [void]

# File lib/rambling/trie/configuration/properties.rb, line 38
def reset
  reset_readers
  reset_serializers

  @compressor = Rambling::Trie::Compressor.new
  @root_builder = -> { Rambling::Trie::Nodes::Raw.new }
  @tmp_path = '/tmp'
end

Private Instance Methods

reset_readers() click to toggle source
# File lib/rambling/trie/configuration/properties.rb, line 51
def reset_readers
  plain_text_reader = Rambling::Trie::Readers::PlainText.new

  @readers = Rambling::Trie::Configuration::ProviderCollection.new(
    :reader,
    txt: plain_text_reader,
  )
end
reset_serializers() click to toggle source
# File lib/rambling/trie/configuration/properties.rb, line 60
def reset_serializers
  marshal_serializer = Rambling::Trie::Serializers::Marshal.new
  yaml_serializer = Rambling::Trie::Serializers::Yaml.new
  zip_serializer = Rambling::Trie::Serializers::Zip.new self

  @serializers = Rambling::Trie::Configuration::ProviderCollection.new(
    :serializer,
    marshal: marshal_serializer,
    yml: yaml_serializer,
    yaml: yaml_serializer,
    zip: zip_serializer,
  )
end