Class: Relaton::Core::HitCollection
- Inherits:
-
Object
- Object
- Relaton::Core::HitCollection
- Extended by:
- Forwardable
- Defined in:
- lib/relaton/core/hit_collection.rb
Instance Attribute Summary collapse
- #fetched ⇒ TrueClass, FalseClass readonly
- #ref ⇒ String readonly
- #year ⇒ String readonly
Instance Method Summary collapse
-
#fetch ⇒ self
Fetches hits from the data source.
-
#initialize(ref, year = nil) ⇒ HitCollection
constructor
A new instance of HitCollection.
-
#inspect ⇒ String
Returns String representation of the collection.
- #reduce!(sum, &block) ⇒ Object
-
#select!(&block) ⇒ RelatonBib::HitCollection
Selects matching hits and returns a new collection.
-
#to_s ⇒ String
Returns String representation of the collection.
Constructor Details
#initialize(ref, year = nil) ⇒ HitCollection
Returns a new instance of HitCollection.
24 25 26 27 28 29 |
# File 'lib/relaton/core/hit_collection.rb', line 24 def initialize(ref, year = nil) @array = [] @ref = ref @year = year @fetched = false end |
Instance Attribute Details
#fetched ⇒ TrueClass, FalseClass (readonly)
12 13 14 |
# File 'lib/relaton/core/hit_collection.rb', line 12 def fetched @fetched end |
#ref ⇒ String (readonly)
15 16 17 |
# File 'lib/relaton/core/hit_collection.rb', line 15 def ref @ref end |
#year ⇒ String (readonly)
18 19 20 |
# File 'lib/relaton/core/hit_collection.rb', line 18 def year @year end |
Instance Method Details
#fetch ⇒ self
Fetches hits from the data source
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/relaton/core/hit_collection.rb', line 36 def fetch workers = WorkersPool.new 4 workers.worker(&:item) each do |hit| workers << hit end workers.end workers.result @fetched = true self end |
#inspect ⇒ String
Returns String representation of the collection
101 102 103 |
# File 'lib/relaton/core/hit_collection.rb', line 101 def inspect "<#{self.class}:#{format('%#.14x', object_id << 1)} @ref=#{@ref} @fetched=#{@fetched}>" end |
#reduce!(sum, &block) ⇒ Object
82 83 84 85 |
# File 'lib/relaton/core/hit_collection.rb', line 82 def reduce!(sum, &block) @array = @array.reduce sum, &block self end |
#select!(&block) ⇒ RelatonBib::HitCollection
Selects matching hits and returns a new collection
77 78 79 80 |
# File 'lib/relaton/core/hit_collection.rb', line 77 def select!(&block) @array.select!(&block) self end |
#to_s ⇒ String
Returns String representation of the collection
92 93 94 |
# File 'lib/relaton/core/hit_collection.rb', line 92 def to_s inspect end |