@@ -224,7 +224,7 @@ def configure(opts)
224224 else
225225 raise TypeError , "can't convert #{ opts . class } into Hash"
226226 end
227- for key , value in opts
227+ opts . each do | key , value |
228228 instance_variable_set "@#{ key } " , value
229229 end
230230 @indent = opts [ :indent ] if opts . key? ( :indent )
@@ -260,7 +260,7 @@ def configure(opts)
260260 # passed to the configure method.
261261 def to_h
262262 result = { }
263- for iv in instance_variables
263+ instance_variables . each do | iv |
264264 iv = iv . to_s [ 1 ..-1 ]
265265 result [ iv . to_sym ] = self [ iv ]
266266 end
@@ -327,20 +327,15 @@ def json_shift(state)
327327 end
328328
329329 def json_transform ( state )
330- delim = ','
331- delim << state . object_nl
332- result = '{'
333- result << state . object_nl
330+ delim = ",#{ state . object_nl } "
331+ result = "{#{ state . object_nl } "
334332 depth = state . depth += 1
335333 first = true
336334 indent = !state . object_nl . empty?
337- each { |key , value |
335+ each { |key , value |
338336 result << delim unless first
339337 result << state . indent * depth if indent
340- result << key . to_s . to_json ( state )
341- result << state . space_before
342- result << ':'
343- result << state . space
338+ result = "#{ result } #{ key . to_s . to_json ( state ) } #{ state . space_before } :#{ state . space } "
344339 if value . respond_to? ( :to_json )
345340 result << value . to_json ( state )
346341 else
0 commit comments