Class: Wayfarer::Frontiers::MemoryTrieFrontier Private

Inherits:
MemoryFrontier show all
Defined in:
lib/wayfarer/frontiers/memory_trie_frontier.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

An in-memory trie.

Instance Attribute Summary

Attributes inherited from Frontier

#config

Instance Method Summary collapse

Methods inherited from MemoryFrontier

#current_uris, #stage, #staged?, #staged_uris

Methods inherited from Frontier

#current_uris, #cycle, #filter_staged_uris!, #reset_staged_uris!, #stage, #staged?, #staged_uris, #swap!

Constructor Details

#initialize(config) ⇒ MemoryTrieFrontier

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of MemoryTrieFrontier.



10
11
12
13
# File 'lib/wayfarer/frontiers/memory_trie_frontier.rb', line 10

def initialize(config)
  @trie = Trie.new
  super(config)
end

Instance Method Details

#cache(*uris) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



16
17
18
# File 'lib/wayfarer/frontiers/memory_trie_frontier.rb', line 16

def cache(*uris)
  uris.each { |uri| @trie.add(uri.to_s) }
end

#cached?(uri) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


25
26
27
28
29
30
# File 'lib/wayfarer/frontiers/memory_trie_frontier.rb', line 25

def cached?(uri)
  # RuboCop autocorrects `#has_key?` to `#key?` otherwise
  # rubocop:disable Style/PreferredHashMethods
  @trie.has_key?(uri.to_s)
  # rubocop:enable Style/PreferredHashMethods
end

#freeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



33
34
35
36
# File 'lib/wayfarer/frontiers/memory_trie_frontier.rb', line 33

def free
  @trie = nil
  super
end

#match!(uri) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



21
22
23
# File 'lib/wayfarer/frontiers/memory_trie_frontier.rb', line 21

def match!(uri)
  @str_or_regexp === uri.host
end