Class: SortedLruFiles

Inherits:
Object
  • Object
show all
Defined in:
lib/hooks/all_files.rb

Overview

Matches suffixes of an array of urls Converts suffixes to prefixes

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSortedLruFiles

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

#msbsObject (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

Parameters:

  • apages (Array[APage])


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_searchObject



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