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.
21 22 23 |
# File 'lib/hooks/all_files.rb', line 21 def initialize @msbs = MSlinnBinarySearch.new i[url start_with?] end |
Instance Attribute Details
#msbs ⇒ Object (readonly)
Returns the value of attribute msbs.
19 20 21 |
# File 'lib/hooks/all_files.rb', line 19 def msbs @msbs end |
Instance Method Details
#add_pages(apages) ⇒ Object
26 27 28 29 |
# File 'lib/hooks/all_files.rb', line 26 def add_pages(apages) apages.each { |apage| insert apage.href, apage } @msbs.enable_search end |
#enable_search ⇒ Object
31 32 33 |
# File 'lib/hooks/all_files.rb', line 31 def enable_search @msbs.enable_search end |
#find(suffix) ⇒ Object
35 36 37 |
# File 'lib/hooks/all_files.rb', line 35 def find(suffix) @msbs.find suffix end |
#insert(url, file) ⇒ Object
39 40 41 42 43 |
# File 'lib/hooks/all_files.rb', line 39 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
45 46 47 |
# File 'lib/hooks/all_files.rb', line 45 def select(suffix) @msbs.select_pages suffix end |