Class: Indexer101::Index
- Inherits:
-
Object
- Object
- Indexer101::Index
- Defined in:
- lib/indexer101.rb
Instance Attribute Summary collapse
-
#h ⇒ Object
readonly
Returns the value of attribute h.
-
#index ⇒ Object
Returns the value of attribute index.
-
#uri_index ⇒ Object
Returns the value of attribute uri_index.
Instance Method Summary collapse
- #build(a) ⇒ Object
-
#initialize ⇒ Index
constructor
A new instance of Index.
- #inspect ⇒ Object
Constructor Details
#initialize ⇒ Index
Returns a new instance of Index.
20 21 22 23 24 25 26 |
# File 'lib/indexer101.rb', line 20 def initialize() @uri_index = {} # contains each URI long with the title @index = {} # contains eack keyword @h = {} # nested keywords constructed from shared string keys end |
Instance Attribute Details
#h ⇒ Object (readonly)
Returns the value of attribute h.
17 18 19 |
# File 'lib/indexer101.rb', line 17 def h @h end |
#index ⇒ Object
Returns the value of attribute index.
18 19 20 |
# File 'lib/indexer101.rb', line 18 def index @index end |
#uri_index ⇒ Object
Returns the value of attribute uri_index.
18 19 20 |
# File 'lib/indexer101.rb', line 18 def uri_index @uri_index end |
Instance Method Details
#build(a) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/indexer101.rb', line 28 def build(a) threads = [] if @index.empty? then threads << Thread.new do @index = Hash[a.map(&:to_sym).zip([''] * a.length)] end end threads << Thread.new { @h = group a } ThreadsWait.all_waits(*threads) end |
#inspect ⇒ Object
43 44 45 46 |
# File 'lib/indexer101.rb', line 43 def inspect() h = @h ? @h.inspect[0..30] + "..." : nil "#<Indexer101::Index @h=#{h.inspect}>" end |