Class: BSONInput

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/mongo-hadoop/input.rb

Direct Known Subclasses

BSONKeyValueInput

Instance Method Summary collapse

Constructor Details

#initialize(stream = nil) ⇒ BSONInput

Returns a new instance of BSONInput.



4
5
6
# File 'lib/mongo-hadoop/input.rb', line 4

def initialize(stream=nil)
  @stream = stream || $stdin
end

Instance Method Details

#eachObject



16
17
18
19
20
# File 'lib/mongo-hadoop/input.rb', line 16

def each
  while(doc = read)
    yield doc
  end
end

#readObject



8
9
10
11
12
13
14
# File 'lib/mongo-hadoop/input.rb', line 8

def read
  begin
    BSON.read_bson_document(@stream)
  rescue NoMethodError
    nil
  end
end