Class: Ppjson::StreamJsonWriter
- Inherits:
-
Object
- Object
- Ppjson::StreamJsonWriter
- Defined in:
- lib/ppjson/stream_json_writer.rb
Instance Attribute Summary collapse
-
#stream ⇒ Object
readonly
Returns the value of attribute stream.
Instance Method Summary collapse
-
#initialize(stream = $stdout) ⇒ StreamJsonWriter
constructor
A new instance of StreamJsonWriter.
- #write(json, options = {:pretty => true}) ⇒ Object
Constructor Details
#initialize(stream = $stdout) ⇒ StreamJsonWriter
Returns a new instance of StreamJsonWriter.
5 6 7 |
# File 'lib/ppjson/stream_json_writer.rb', line 5 def initialize(stream = $stdout) @stream = stream end |
Instance Attribute Details
#stream ⇒ Object (readonly)
Returns the value of attribute stream.
3 4 5 |
# File 'lib/ppjson/stream_json_writer.rb', line 3 def stream @stream end |
Instance Method Details
#write(json, options = {:pretty => true}) ⇒ Object
9 10 11 12 |
# File 'lib/ppjson/stream_json_writer.rb', line 9 def write(json, = {:pretty => true}) hash = from_json(json) stream.puts MultiJson.dump(hash, ) end |