summaryrefslogtreecommitdiff
path: root/doc/classes/JSON/Pure/Generator/State.html
blob: 984046cad5bdc3d0b97559f7a98d3e4d221f4699 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>JSON::Pure::Generator::State</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="../../../../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../../css/github.css" type="text/css" media="screen" />
<script src="../../../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>     
    <div class="banner">
        
        <h1>
            <span class="type">Class</span> 
            JSON::Pure::Generator::State 
            
                <span class="parent">&lt; 
                    
                    Object
                    
                </span>
            
        </h1>
        <ul class="files">
            
            <li><a href="../../../../files/lib/json/pure/generator_rb.html">lib/json/pure/generator.rb</a></li>
            
        </ul>
    </div>
    <div id="bodyContent">
        <div id="content">
  
    <div class="description">
      
<p>This class is used to create <a href="State.html">State</a> instances, that
are use to hold data while generating a <a
href="../../../JSON.html">JSON</a> text from a Ruby data structure.</p>

    </div>
  


  


  
  


  


  
    <!-- Method ref -->
    <div class="sectiontitle">Methods</div>
    <dl class="methods">
      
        <dt>#</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="#method-i-5B-5D">[]</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>A</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="#method-i-allow_nan-3F">allow_nan?</a>,
              </li>
            
              
              <li>
                <a href="#method-i-ascii_only-3F">ascii_only?</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>C</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="#method-i-check_circular-3F">check_circular?</a>,
              </li>
            
              
              <li>
                <a href="#method-i-configure">configure</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>F</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="#method-c-from_state">from_state</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>G</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="#method-i-generate">generate</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>M</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="#method-i-merge">merge</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>N</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="#method-c-new">new</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>Q</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="#method-i-quirks_mode-3F">quirks_mode?</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>T</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="#method-i-to_h">to_h</a>
              </li>
            
          </ul>
        </dd>
      
    </dl>
  

  



  

    

    

    


    
      <!-- Section attributes -->
      <div class="sectiontitle">Attributes</div>
      <table border='0' cellpadding='5'>
        
          <tr valign='top'>
            <td class='attr-rw'>
              [RW]
            </td>
            <td class='attr-name'>array_nl</td>
            <td class='attr-desc'><p>This string is put at the end of a line that holds a <a
href="../../../JSON.html">JSON</a> array.</p></td>
          </tr>
        
          <tr valign='top'>
            <td class='attr-rw'>
              [RW]
            </td>
            <td class='attr-name'>depth</td>
            <td class='attr-desc'><p>This integer returns the current depth data structure nesting in the
generated <a href="../../../JSON.html">JSON</a>.</p></td>
          </tr>
        
          <tr valign='top'>
            <td class='attr-rw'>
              [RW]
            </td>
            <td class='attr-name'>indent</td>
            <td class='attr-desc'><p>This string is used to indent levels in the <a
href="../../../JSON.html">JSON</a> text.</p></td>
          </tr>
        
          <tr valign='top'>
            <td class='attr-rw'>
              [RW]
            </td>
            <td class='attr-name'>max_nesting</td>
            <td class='attr-desc'><p>This integer returns the maximum level of data structure nesting in the
generated <a href="../../../JSON.html">JSON</a>, <a
href="State.html#attribute-i-max_nesting">#max_nesting</a> = 0 if no
maximum is checked.</p></td>
          </tr>
        
          <tr valign='top'>
            <td class='attr-rw'>
              [RW]
            </td>
            <td class='attr-name'>object_nl</td>
            <td class='attr-desc'><p>This string is put at the end of a line that holds a <a
href="../../../JSON.html">JSON</a> object (or Hash).</p></td>
          </tr>
        
          <tr valign='top'>
            <td class='attr-rw'>
              [RW]
            </td>
            <td class='attr-name'>quirks_mode</td>
            <td class='attr-desc'><p>If this attribute is set to true, quirks mode is enabled, otherwise it’s
disabled.</p></td>
          </tr>
        
          <tr valign='top'>
            <td class='attr-rw'>
              [RW]
            </td>
            <td class='attr-name'>space</td>
            <td class='attr-desc'><p>This string is used to insert a space between the tokens in a <a
href="../../../JSON.html">JSON</a> string.</p></td>
          </tr>
        
          <tr valign='top'>
            <td class='attr-rw'>
              [RW]
            </td>
            <td class='attr-name'>space_before</td>
            <td class='attr-desc'><p>This string is used to insert a space before the ‘:’ in <a
href="../../../JSON.html">JSON</a> objects.</p></td>
          </tr>
        
      </table>
    


    <!-- Methods -->
    
      <div class="sectiontitle">Class Public methods</div>
      
        <div class="method">
          <div class="title method-title" id="method-c-from_state">
            
              <a name="method-c-from_state"></a><b>from_state</b>(opts)
            
          </div>
          
          
            <div class="description">
              <p>Creates a <a href="State.html">State</a> object from <em>opts</em>, which
ought to be Hash to create a new <a href="State.html">State</a> instance
configured by <em>opts</em>, something else to create an unconfigured
instance. If <em>opts</em> is a <a href="State.html">State</a> object, it
is just returned.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-c-from_state_source')" id="l_method-c-from_state_source">show</a>
                
              </p>
              <div id="method-c-from_state_source" class="dyn-source">
                <pre><span class="ruby-comment"># File lib/json/pure/generator.rb, line 108</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">self</span>.<span class="ruby-identifier">from_state</span>(<span class="ruby-identifier">opts</span>)
  <span class="ruby-keyword">case</span>
  <span class="ruby-keyword">when</span> <span class="ruby-keyword">self</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">opts</span>
    <span class="ruby-identifier">opts</span>
  <span class="ruby-keyword">when</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:to_hash</span>)
    <span class="ruby-identifier">new</span>(<span class="ruby-identifier">opts</span>.<span class="ruby-identifier">to_hash</span>)
  <span class="ruby-keyword">when</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:to_h</span>)
    <span class="ruby-identifier">new</span>(<span class="ruby-identifier">opts</span>.<span class="ruby-identifier">to_h</span>)
  <span class="ruby-keyword">else</span>
    <span class="ruby-constant">SAFE_STATE_PROTOTYPE</span>.<span class="ruby-identifier">dup</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-c-new">
            
              <a name="method-c-new"></a><b>new</b>(opts = {})
            
          </div>
          
          
            <div class="description">
              <p>Instantiates a new <a href="State.html">State</a> object, configured by
<em>opts</em>.</p>

<p><em>opts</em> can have the following keys:</p>
<ul><li>
<p><strong>indent</strong>: a string used to indent levels (default: ”),</p>
</li><li>
<p><strong>space</strong>: a string that is put after, a : or , delimiter
(default: ”),</p>
</li><li>
<p><strong><a
href="State.html#attribute-i-space_before">#space_before</a></strong>: a
string that is put before a : pair delimiter (default: ”),</p>
</li><li>
<p><strong><a href="State.html#attribute-i-object_nl">#object_nl</a></strong>:
a string that is put at the end of a <a href="../../../JSON.html">JSON</a>
object (default: ”),</p>
</li><li>
<p><strong><a href="State.html#attribute-i-array_nl">#array_nl</a></strong>: a
string that is put at the end of a <a href="../../../JSON.html">JSON</a>
array (default: ”),</p>
</li><li>
<p><strong>check_circular</strong>: is deprecated now, use the :<a
href="State.html#attribute-i-max_nesting">#max_nesting</a> option instead,</p>
</li><li>
<p><strong><a
href="State.html#attribute-i-max_nesting">#max_nesting</a></strong>: sets
the maximum level of data structure nesting in the generated <a
href="../../../JSON.html">JSON</a>, <a
href="State.html#attribute-i-max_nesting">#max_nesting</a> = 0 if no
maximum should be checked.</p>
</li><li>
<p><strong>allow_nan</strong>: true if NaN, Infinity, and -Infinity should be
generated, otherwise an exception is thrown, if these values are
encountered. This options defaults to false.</p>
</li><li>
<p><strong><a
href="State.html#attribute-i-quirks_mode">#quirks_mode</a></strong>:
Enables <a href="State.html#attribute-i-quirks_mode">#quirks_mode</a> for
parser, that is for example generating single <a
href="../../../JSON.html">JSON</a> values instead of documents is possible.</p>
</li></ul>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-c-new_source')" id="l_method-c-new_source">show</a>
                
              </p>
              <div id="method-c-new_source" class="dyn-source">
                <pre><span class="ruby-comment"># File lib/json/pure/generator.rb, line 138</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">initialize</span>(<span class="ruby-identifier">opts</span> = {})
  <span class="ruby-ivar">@indent</span>                = <span class="ruby-string">''</span>
  <span class="ruby-ivar">@space</span>                 = <span class="ruby-string">''</span>
  <span class="ruby-ivar">@space_before</span>          = <span class="ruby-string">''</span>
  <span class="ruby-ivar">@object_nl</span>             = <span class="ruby-string">''</span>
  <span class="ruby-ivar">@array_nl</span>              = <span class="ruby-string">''</span>
  <span class="ruby-ivar">@allow_nan</span>             = <span class="ruby-keyword">false</span>
  <span class="ruby-ivar">@ascii_only</span>            = <span class="ruby-keyword">false</span>
  <span class="ruby-ivar">@quirks_mode</span>           = <span class="ruby-keyword">false</span>
  <span class="ruby-ivar">@buffer_initial_length</span> = <span class="ruby-number">1024</span>
  <span class="ruby-identifier">configure</span> <span class="ruby-identifier">opts</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
                  
      <div class="sectiontitle">Instance Public methods</div>
      
        <div class="method">
          <div class="title method-title" id="method-i-5B-5D">
            
              <a name="method-i-5B-5D"></a><b>[]</b>(name)
            
          </div>
          
          
            <div class="description">
              <p>Return the value returned by method <code>name</code>.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-5B-5D_source')" id="l_method-i-5B-5D_source">show</a>
                
              </p>
              <div id="method-i-5B-5D_source" class="dyn-source">
                <pre><span class="ruby-comment"># File lib/json/pure/generator.rb, line 265</span>
<span class="ruby-keyword">def</span> <span class="ruby-operator">[]</span>(<span class="ruby-keyword ruby-title">name</span>)
  <span class="ruby-identifier">__send__</span> <span class="ruby-identifier">name</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-allow_nan-3F">
            
              <a name="method-i-allow_nan-3F"></a><b>allow_nan?</b>()
            
          </div>
          
          
            <div class="description">
              <p>Returns true if NaN, Infinity, and -Infinity should be considered as valid
<a href="../../../JSON.html">JSON</a> and output.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-allow_nan-3F_source')" id="l_method-i-allow_nan-3F_source">show</a>
                
              </p>
              <div id="method-i-allow_nan-3F_source" class="dyn-source">
                <pre><span class="ruby-comment"># File lib/json/pure/generator.rb, line 205</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">allow_nan?</span>
  <span class="ruby-ivar">@allow_nan</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-ascii_only-3F">
            
              <a name="method-i-ascii_only-3F"></a><b>ascii_only?</b>()
            
          </div>
          
          
            <div class="description">
              <p>Returns true, if only ASCII characters should be generated. Otherwise
returns false.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-ascii_only-3F_source')" id="l_method-i-ascii_only-3F_source">show</a>
                
              </p>
              <div id="method-i-ascii_only-3F_source" class="dyn-source">
                <pre><span class="ruby-comment"># File lib/json/pure/generator.rb, line 211</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">ascii_only?</span>
  <span class="ruby-ivar">@ascii_only</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-check_circular-3F">
            
              <a name="method-i-check_circular-3F"></a><b>check_circular?</b>()
            
          </div>
          
          
            <div class="description">
              <p>Returns true, if circular data structures are checked, otherwise returns
false.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-check_circular-3F_source')" id="l_method-i-check_circular-3F_source">show</a>
                
              </p>
              <div id="method-i-check_circular-3F_source" class="dyn-source">
                <pre><span class="ruby-comment"># File lib/json/pure/generator.rb, line 199</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">check_circular?</span>
  <span class="ruby-operator">!</span><span class="ruby-ivar">@max_nesting</span>.<span class="ruby-identifier">zero?</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-configure">
            
              <a name="method-i-configure"></a><b>configure</b>(opts)
            
          </div>
          
          
            <div class="description">
              <p>Configure this <a href="State.html">State</a> instance with the Hash
<em>opts</em>, and return itself.</p>
            </div>
          
          
          
            <div class="aka">
              Also aliased as: <a href="State.html#method-i-merge">merge</a>
            </div>
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-configure_source')" id="l_method-i-configure_source">show</a>
                
              </p>
              <div id="method-i-configure_source" class="dyn-source">
                <pre><span class="ruby-comment"># File lib/json/pure/generator.rb, line 222</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">configure</span>(<span class="ruby-identifier">opts</span>)
  <span class="ruby-ivar">@indent</span>         = <span class="ruby-identifier">opts</span>[<span class="ruby-value">:indent</span>] <span class="ruby-keyword">if</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value">:indent</span>)
  <span class="ruby-ivar">@space</span>          = <span class="ruby-identifier">opts</span>[<span class="ruby-value">:space</span>] <span class="ruby-keyword">if</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value">:space</span>)
  <span class="ruby-ivar">@space_before</span>   = <span class="ruby-identifier">opts</span>[<span class="ruby-value">:space_before</span>] <span class="ruby-keyword">if</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value">:space_before</span>)
  <span class="ruby-ivar">@object_nl</span>      = <span class="ruby-identifier">opts</span>[<span class="ruby-value">:object_nl</span>] <span class="ruby-keyword">if</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value">:object_nl</span>)
  <span class="ruby-ivar">@array_nl</span>       = <span class="ruby-identifier">opts</span>[<span class="ruby-value">:array_nl</span>] <span class="ruby-keyword">if</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value">:array_nl</span>)
  <span class="ruby-ivar">@allow_nan</span>      = <span class="ruby-operator">!</span><span class="ruby-operator">!</span><span class="ruby-identifier">opts</span>[<span class="ruby-value">:allow_nan</span>] <span class="ruby-keyword">if</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value">:allow_nan</span>)
  <span class="ruby-ivar">@ascii_only</span>     = <span class="ruby-identifier">opts</span>[<span class="ruby-value">:ascii_only</span>] <span class="ruby-keyword">if</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value">:ascii_only</span>)
  <span class="ruby-ivar">@depth</span>          = <span class="ruby-identifier">opts</span>[<span class="ruby-value">:depth</span>] <span class="ruby-operator">||</span> <span class="ruby-number">0</span>
  <span class="ruby-ivar">@quirks_mode</span>    = <span class="ruby-identifier">opts</span>[<span class="ruby-value">:quirks_mode</span>] <span class="ruby-keyword">if</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value">:quirks_mode</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">opts</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value">:max_nesting</span>) <span class="ruby-comment"># defaults to 19</span>
    <span class="ruby-ivar">@max_nesting</span> = <span class="ruby-number">19</span>
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value">:max_nesting</span>]
    <span class="ruby-ivar">@max_nesting</span> = <span class="ruby-identifier">opts</span>[<span class="ruby-value">:max_nesting</span>]
  <span class="ruby-keyword">else</span>
    <span class="ruby-ivar">@max_nesting</span> = <span class="ruby-number">0</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-generate">
            
              <a name="method-i-generate"></a><b>generate</b>(obj)
            
          </div>
          
          
            <div class="description">
              <p>Generates a valid <a href="../../../JSON.html">JSON</a> document from
object <code>obj</code> and returns the result. If no valid <a
href="../../../JSON.html">JSON</a> document can be created this method
raises a <a href="../../GeneratorError.html">GeneratorError</a> exception.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-generate_source')" id="l_method-i-generate_source">show</a>
                
              </p>
              <div id="method-i-generate_source" class="dyn-source">
                <pre><span class="ruby-comment"># File lib/json/pure/generator.rb, line 256</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">generate</span>(<span class="ruby-identifier">obj</span>)
  <span class="ruby-identifier">result</span> = <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">to_json</span>(<span class="ruby-keyword">self</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-ivar">@quirks_mode</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">result</span> <span class="ruby-operator">!~</span> <span class="ruby-regexp">/\A\s*(?:\[.*\]|\{.*\})\s*\Z/</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">GeneratorError</span>, <span class="ruby-string">&quot;only generation of JSON objects or arrays allowed&quot;</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">result</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-merge">
            
              <a name="method-i-merge"></a><b>merge</b>(opts)
            
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-quirks_mode-3F">
            
              <a name="method-i-quirks_mode-3F"></a><b>quirks_mode?</b>()
            
          </div>
          
          
            <div class="description">
              <p>Returns true, if quirks mode is enabled. Otherwise returns false.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-quirks_mode-3F_source')" id="l_method-i-quirks_mode-3F_source">show</a>
                
              </p>
              <div id="method-i-quirks_mode-3F_source" class="dyn-source">
                <pre><span class="ruby-comment"># File lib/json/pure/generator.rb, line 216</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">quirks_mode?</span>
  <span class="ruby-ivar">@quirks_mode</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-to_h">
            
              <a name="method-i-to_h"></a><b>to_h</b>()
            
          </div>
          
          
            <div class="description">
              <p>Returns the configuration instance variables as a hash, that can be passed
to the configure method.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-to_h_source')" id="l_method-i-to_h_source">show</a>
                
              </p>
              <div id="method-i-to_h_source" class="dyn-source">
                <pre><span class="ruby-comment"># File lib/json/pure/generator.rb, line 245</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">to_h</span>
  <span class="ruby-identifier">result</span> = {}
  <span class="ruby-keyword">for</span> <span class="ruby-identifier">iv</span> <span class="ruby-keyword">in</span> <span class="ruby-node">]indent space space_before object_nl array_nl allow_nan max_nesting ascii_only quirks_mode buffer_initial_length depth]</span>
    <span class="ruby-identifier">result</span>[<span class="ruby-identifier">iv</span>.<span class="ruby-identifier">intern</span>] = <span class="ruby-identifier">instance_variable_get</span>(<span class="ruby-node">&quot;@#{iv}&quot;</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">result</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
                    </div>
    </div>
  </body>
</html>