Class: SortedLruFiles
- Inherits:
-
Object
- Object
- SortedLruFiles
- Defined in:
- lib/hooks/all_files.rb
Overview
Matches suffixes of an array of urls Converts suffixes to prefixes
Instance Attribute Summary collapse
-
#msbs ⇒ Object
readonly
Returns the value of attribute msbs.
Instance Method Summary collapse
- #add_pages(apages) ⇒ Object
- #enable_search ⇒ Object
- #find(suffix) ⇒ Object
-
#initialize ⇒ SortedLruFiles
constructor
A new instance of SortedLruFiles.
- #insert(url, file) ⇒ Object
- #select(suffix) ⇒ Object
Constructor Details
#initialize ⇒ SortedLruFiles
Returns a new instance of SortedLruFiles.
19 20 21 |
# File 'lib/hooks/all_files.rb', line 19 def initialize @msbs = MSlinnBinarySearch.new %i[url start_with?] end |
Instance Attribute Details
#msbs ⇒ Object (readonly)
Returns the value of attribute msbs.
17 18 19 |
# File 'lib/hooks/all_files.rb', line 17 def msbs @msbs end |
Instance Method Details
#add_pages(apages) ⇒ Object
24 25 26 27 |
# File 'lib/hooks/all_files.rb', line 24 def add_pages(apages) apages.each { |apage| insert apage.href, apage } @msbs.enable_search end |
#enable_search ⇒ Object
29 30 31 |
# File 'lib/hooks/all_files.rb', line 29 def enable_search @msbs.enable_search end |
#find(suffix) ⇒ Object
33 34 35 |
# File 'lib/hooks/all_files.rb', line 33 def find(suffix) @msbs.find suffix end |
#insert(url, file) ⇒ Object
37 38 39 40 41 |
# File 'lib/hooks/all_files.rb', line 37 def insert(url, file) lru_file = LruFile.new(url.reverse, file) lru_file.new_chain [:url, %i[start_with? placeholder]] @msbs.insert(lru_file) end |
#select(suffix) ⇒ Object
43 44 45 |
# File 'lib/hooks/all_files.rb', line 43 def select(suffix) @msbs.select_pages suffix end |