# File lib/json/common.rb, line 204 204: def pretty_generate(obj, opts = nil) 205: state = JSON.state.new( 206: :indent => ' ', 207: :space => ' ', 208: :object_nl => "\n", 209: :array_nl => "\n", 210: :check_circular => true 211: ) 212: if opts 213: if opts.respond_to? :to_hash 214: opts = opts.to_hash 215: elsif opts.respond_to? :to_h 216: opts = opts.to_h 217: else 218: raise TypeError, "can't convert #{opts.class} into Hash" 219: end 220: state.configure(opts) 221: end 222: obj.to_json(state) 223: end