Class: RubyReduce::OutputWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_reduce/out_put.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ OutputWriter

Returns a new instance of OutputWriter.



3
4
5
6
7
# File 'lib/ruby_reduce/out_put.rb', line 3

def initialize(options)
  @collection_name = options

  @mongo_db = Mongo::Connection.new(RubyReduce.mongo_connection).db(RubyReduce.mongo_db)
end

Instance Method Details

#write(data) ⇒ Object



9
10
11
12
13
14
# File 'lib/ruby_reduce/out_put.rb', line 9

def write(data)
  @mongo_db[@collection_name].remove()
  data.each do |key, values|
    @mongo_db[@collection_name].insert({:_id => key, :value => values})
  end
end