Class: Wayfarer::Frontiers::MemoryFrontier Private
- Defined in:
- lib/wayfarer/frontiers/memory_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.
A naive in-memory frontier.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Frontier
Instance Method Summary collapse
- #cache(*uris) ⇒ Object private
- #cached?(uri) ⇒ Boolean private
- #current_uris ⇒ Object private
- #free ⇒ Object private
-
#initialize(config) ⇒ MemoryFrontier
constructor
private
A new instance of MemoryFrontier.
- #stage(*uris) ⇒ Object private
- #staged?(uri) ⇒ Boolean private
- #staged_uris ⇒ Object private
Methods inherited from Frontier
Constructor Details
#initialize(config) ⇒ MemoryFrontier
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 MemoryFrontier.
11 12 13 14 15 16 |
# File 'lib/wayfarer/frontiers/memory_frontier.rb', line 11 def initialize(config) @current_uris = Set.new([]) @staged_uris = Set.new([]) @cached_uris = Set.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.
43 44 45 46 47 48 49 |
# File 'lib/wayfarer/frontiers/memory_frontier.rb', line 43 def cache(*uris) @cached_uris |= if JAVA_PLATFORM == "java" uris.map(&:to_s) else Parallel.map(uris, &:to_s) end 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.
52 53 54 |
# File 'lib/wayfarer/frontiers/memory_frontier.rb', line 52 def cached?(uri) @cached_uris.include?(uri.to_s) end |
#current_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.
19 20 21 22 23 24 25 |
# File 'lib/wayfarer/frontiers/memory_frontier.rb', line 19 def current_uris if JAVA_PLATFORM == "java" @current_uris.map { |uri| URI(uri) } else Parallel.map(@current_uris) { |uri| URI(uri) } end end |
#free ⇒ 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.
57 58 59 |
# File 'lib/wayfarer/frontiers/memory_frontier.rb', line 57 def free @current_uris = @staged_uris = @cached_uris = nil end |
#stage(*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.
33 34 35 |
# File 'lib/wayfarer/frontiers/memory_frontier.rb', line 33 def stage(*uris) @staged_uris |= uris end |
#staged?(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.
38 39 40 |
# File 'lib/wayfarer/frontiers/memory_frontier.rb', line 38 def staged?(uri) @staged_uris.include?(uri.to_s) end |
#staged_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.
28 29 30 |
# File 'lib/wayfarer/frontiers/memory_frontier.rb', line 28 def staged_uris @staged_uris.to_a # These are assumed to be URIs already, so no map end |