Class: Tb::JSONWriter
- Inherits:
-
HashWriter
- Object
- HashWriter
- Tb::JSONWriter
- Defined in:
- lib/tb/json.rb
Instance Method Summary collapse
-
#initialize(io) ⇒ JSONWriter
constructor
A new instance of JSONWriter.
Methods inherited from HashWriter
#finish, #header_generator=, #header_required?, #put_hash
Constructor Details
#initialize(io) ⇒ JSONWriter
Returns a new instance of JSONWriter.
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/tb/json.rb', line 40 def initialize(io) io << "[\n" sep = "" super lambda {|hash| io << sep << JSON.pretty_generate(hash) sep = ",\n" }, lambda { io << "\n]\n" } end |