Class: RemoteRuby::Unmarshaler
- Inherits:
-
Object
- Object
- RemoteRuby::Unmarshaler
- Defined in:
- lib/remote_ruby/unmarshaler.rb
Overview
Unmarshals variables from given stream
Constant Summary collapse
- UnmarshalError =
Class.new(StandardError)
Instance Method Summary collapse
-
#initialize(stream, terminator = nil) ⇒ Unmarshaler
constructor
A new instance of Unmarshaler.
- #unmarshal ⇒ Object
Constructor Details
#initialize(stream, terminator = nil) ⇒ Unmarshaler
Returns a new instance of Unmarshaler.
8 9 10 11 |
# File 'lib/remote_ruby/unmarshaler.rb', line 8 def initialize(stream, terminator = nil) @stream = stream @terminator = terminator end |
Instance Method Details
#unmarshal ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/remote_ruby/unmarshaler.rb', line 13 def unmarshal res = {} until stream.eof? line = stream.readline break if terminator && line == terminator var = read_var(line) res[var.first] = var[1] end res end |