Class: EDN::Reader

Inherits:
Object
  • Object
show all
Defined in:
lib/edn/reader.rb

Instance Method Summary collapse

Constructor Details

#initialize(source) ⇒ Reader

Returns a new instance of Reader


4
5
6
# File 'lib/edn/reader.rb', line 4

def initialize(source)
  @parser = EDN.new_parser(source)
end

Instance Method Details

#eachObject


17
18
19
20
21
# File 'lib/edn/reader.rb', line 17

def each
  until (result = @parser.read) == EOF
    yield result
  end
end

#read(eof_value = NOTHING) ⇒ Object


8
9
10
11
12
13
14
15
# File 'lib/edn/reader.rb', line 8

def read(eof_value = NOTHING)
  result = @parser.read
  if result == EOF 
    raise "Unexpected end of file" if eof_value == NOTHING
    return eof_value
  end
  result
end