Class: Turn::BucketMap
- Inherits:
-
Object
- Object
- Turn::BucketMap
- Defined in:
- lib/turn/bucket_map.rb
Instance Attribute Summary collapse
-
#buckets ⇒ Object
Returns the value of attribute buckets.
-
#count ⇒ Object
Returns the value of attribute count.
Instance Method Summary collapse
-
#initialize(term) ⇒ BucketMap
constructor
A new instance of BucketMap.
- #load(dc) ⇒ Object
- #parse(map) ⇒ Object
Constructor Details
#initialize(term) ⇒ BucketMap
Returns a new instance of BucketMap.
9 10 11 12 13 |
# File 'lib/turn/bucket_map.rb', line 9 def initialize(term) @term = term @buckets = [] @count = 0 end |
Instance Attribute Details
#buckets ⇒ Object
Returns the value of attribute buckets.
7 8 9 |
# File 'lib/turn/bucket_map.rb', line 7 def buckets @buckets end |
#count ⇒ Object
Returns the value of attribute count.
7 8 9 |
# File 'lib/turn/bucket_map.rb', line 7 def count @count end |
Instance Method Details
#load(dc) ⇒ Object
15 16 17 |
# File 'lib/turn/bucket_map.rb', line 15 def load(dc) parse(@term.dump_bucket_map(dc)) end |
#parse(map) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/turn/bucket_map.rb', line 19 def parse(map) map.each_with_index do |bucket, index| if /(?<id>\S+):\s+(?<value>\d+)/ =~ bucket @count = value.to_i @buckets[index] = id end end end |