Class: ProfileCollection
- Inherits:
-
Object
- Object
- ProfileCollection
- Defined in:
- lib/logstash/test.rb,
lib/logstash/inputs/mongoprofile.rb
Instance Method Summary collapse
- #each ⇒ Object
- #get_last_document_date ⇒ Object
-
#initialize(documents, parser, generate_id) ⇒ ProfileCollection
constructor
A new instance of ProfileCollection.
- #length ⇒ Object
Constructor Details
#initialize(documents, parser, generate_id) ⇒ ProfileCollection
Returns a new instance of ProfileCollection.
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/logstash/test.rb', line 57 def initialize(documents, parser, generate_id) @generate_id = generate_id @documents = [] documents.each do |document| @documents.push(document) puts document['ts'] end @parser = parser end |
Instance Method Details
#each ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/logstash/test.rb', line 69 def each @documents.each do |document| if @generate_id document['_id'] = generate_id.to_s end yield @parser.parse(document) end @documents = [] end |
#get_last_document_date ⇒ Object
81 82 83 84 85 86 87 |
# File 'lib/logstash/test.rb', line 81 def get_last_document_date if @documents != nil and @documents[-1] != nil @documents[-1]['ts'] else nil end end |
#length ⇒ Object
89 90 91 |
# File 'lib/logstash/test.rb', line 89 def length @documents.length end |