mbrao 1.4.4 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +29 -0
  3. data/.travis.yml +3 -4
  4. data/CHANGELOG.md +5 -0
  5. data/Gemfile +4 -4
  6. data/doc/ActionView.html +125 -0
  7. data/doc/ActionView/Template.html +140 -0
  8. data/doc/ActionView/Template/Handlers.html +3 -3
  9. data/doc/ActionView/Template/Handlers/MbraoTemplate.html +26 -26
  10. data/doc/HTML.html +2 -2
  11. data/doc/HTML/Pipeline.html +2 -2
  12. data/doc/HTML/Pipeline/KramdownFilter.html +4 -4
  13. data/doc/Mbrao.html +3 -3
  14. data/doc/Mbrao/Author.html +29 -29
  15. data/doc/Mbrao/Content.html +1977 -3644
  16. data/doc/Mbrao/ContentInterface.html +817 -0
  17. data/doc/Mbrao/ContentInterface/ClassMethods.html +388 -0
  18. data/doc/Mbrao/Exceptions.html +1 -1
  19. data/doc/Mbrao/Exceptions/InvalidDate.html +1 -1
  20. data/doc/Mbrao/Exceptions/InvalidMetadata.html +1 -1
  21. data/doc/Mbrao/Exceptions/Parsing.html +1 -1
  22. data/doc/Mbrao/Exceptions/Rendering.html +1 -1
  23. data/doc/Mbrao/Exceptions/UnavailableLocalization.html +1 -1
  24. data/doc/Mbrao/Exceptions/Unimplemented.html +1 -1
  25. data/doc/Mbrao/Exceptions/UnknownEngine.html +1 -1
  26. data/doc/Mbrao/Parser.html +12 -12
  27. data/doc/Mbrao/ParserInterface.html +134 -0
  28. data/doc/Mbrao/ParserInterface/ClassMethods.html +1724 -0
  29. data/doc/Mbrao/ParserValidations.html +134 -0
  30. data/doc/Mbrao/ParserValidations/ClassMethods.html +348 -0
  31. data/doc/Mbrao/ParsingEngines.html +1 -1
  32. data/doc/Mbrao/ParsingEngines/Base.html +4 -4
  33. data/doc/Mbrao/ParsingEngines/PlainText.html +25 -15
  34. data/doc/Mbrao/RenderingEngines.html +1 -1
  35. data/doc/Mbrao/RenderingEngines/Base.html +2 -2
  36. data/doc/Mbrao/RenderingEngines/HtmlPipeline.html +173 -169
  37. data/doc/Mbrao/Version.html +3 -3
  38. data/doc/_index.html +51 -24
  39. data/doc/class_list.html +1 -1
  40. data/doc/file.README.html +1 -1
  41. data/doc/index.html +1 -1
  42. data/doc/method_list.html +63 -69
  43. data/doc/top-level-namespace.html +2 -2
  44. data/lib/mbrao.rb +7 -2
  45. data/lib/mbrao/author.rb +5 -5
  46. data/lib/mbrao/content.rb +110 -256
  47. data/lib/mbrao/content_interface.rb +146 -0
  48. data/lib/mbrao/exceptions.rb +1 -1
  49. data/lib/mbrao/integrations/rails.rb +48 -42
  50. data/lib/mbrao/parser.rb +24 -176
  51. data/lib/mbrao/parser_interface.rb +143 -0
  52. data/lib/mbrao/parser_validations.rb +41 -0
  53. data/lib/mbrao/parsing_engines/base.rb +4 -4
  54. data/lib/mbrao/parsing_engines/plain_text.rb +136 -121
  55. data/lib/mbrao/rendering_engines/base.rb +2 -2
  56. data/lib/mbrao/rendering_engines/html_pipeline.rb +52 -77
  57. data/lib/mbrao/rendering_engines/html_pipeline/kramdown_filter.rb +31 -0
  58. data/lib/mbrao/version.rb +2 -2
  59. data/mbrao.gemspec +3 -3
  60. data/spec/mbrao/author_spec.rb +1 -1
  61. data/spec/mbrao/content_spec.rb +1 -1
  62. data/spec/mbrao/parser_spec.rb +16 -16
  63. data/spec/mbrao/rendering_engines/html_pipeline/kramdown_filter_spec.rb +28 -0
  64. data/spec/mbrao/rendering_engines/html_pipeline_spec.rb +0 -21
  65. metadata +23 -8
@@ -124,7 +124,7 @@
124
124
  </div>
125
125
 
126
126
  <div id="footer">
127
- Generated on Wed Apr 9 21:36:01 2014 by
127
+ Generated on Sun May 11 18:17:19 2014 by
128
128
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
129
129
  0.8.7.4 (ruby-2.1.0).
130
130
  </div>
@@ -91,7 +91,7 @@
91
91
 
92
92
 
93
93
  <dt class="r2">Includes:</dt>
94
- <dd class="r2"><span class='object_link'><a href="PublicInterface.html" title="Mbrao::PublicInterface (module)">PublicInterface</a></span>, <span class='object_link'><a href="Validations.html" title="Mbrao::Validations (module)">Validations</a></span></dd>
94
+ <dd class="r2"><span class='object_link'><a href="ParserInterface.html" title="Mbrao::ParserInterface (module)">ParserInterface</a></span>, <span class='object_link'><a href="ParserValidations.html" title="Mbrao::ParserValidations (module)">ParserValidations</a></span></dd>
95
95
 
96
96
 
97
97
 
@@ -275,13 +275,13 @@
275
275
  <pre class="lines">
276
276
 
277
277
 
278
- 173
279
- 174
280
- 175
281
- 176</pre>
278
+ 20
279
+ 21
280
+ 22
281
+ 23</pre>
282
282
  </td>
283
283
  <td>
284
- <pre class="code"><span class="info file"># File 'lib/mbrao/parser.rb', line 173</span>
284
+ <pre class="code"><span class="info file"># File 'lib/mbrao/parser.rb', line 20</span>
285
285
 
286
286
  <span class='kw'>def</span> <span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
287
287
  <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='id identifier rubyid_sanitize_parsing_options'>sanitize_parsing_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
@@ -387,13 +387,13 @@
387
387
  <pre class="lines">
388
388
 
389
389
 
390
- 184
391
- 185
392
- 186
393
- 187</pre>
390
+ 31
391
+ 32
392
+ 33
393
+ 34</pre>
394
394
  </td>
395
395
  <td>
396
- <pre class="code"><span class="info file"># File 'lib/mbrao/parser.rb', line 184</span>
396
+ <pre class="code"><span class="info file"># File 'lib/mbrao/parser.rb', line 31</span>
397
397
 
398
398
  <span class='kw'>def</span> <span class='id identifier rubyid_render'>render</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='id identifier rubyid_context'>context</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
399
399
  <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='id identifier rubyid_sanitize_rendering_options'>sanitize_rendering_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
@@ -409,7 +409,7 @@
409
409
  </div>
410
410
 
411
411
  <div id="footer">
412
- Generated on Wed Apr 9 21:36:00 2014 by
412
+ Generated on Sun May 11 18:17:17 2014 by
413
413
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
414
414
  0.8.7.4 (ruby-2.1.0).
415
415
  </div>
@@ -0,0 +1,134 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Module: Mbrao::ParserInterface
8
+
9
+ &mdash; Documentation by YARD 0.8.7.4
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ hasFrames = window.top.frames.main ? true : false;
19
+ relpath = '../';
20
+ framesUrl = "../frames.html#!Mbrao/ParserInterface.html";
21
+ </script>
22
+
23
+
24
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
25
+
26
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
27
+
28
+
29
+ </head>
30
+ <body>
31
+ <div id="header">
32
+ <div id="menu">
33
+
34
+ <a href="../_index.html">Index (P)</a> &raquo;
35
+ <span class='title'><span class='object_link'><a href="../Mbrao.html" title="Mbrao (module)">Mbrao</a></span></span>
36
+ &raquo;
37
+ <span class="title">ParserInterface</span>
38
+
39
+
40
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41
+ </div>
42
+
43
+ <div id="search">
44
+
45
+ <a class="full_list_link" id="class_list_link"
46
+ href="../class_list.html">
47
+ Class List
48
+ </a>
49
+
50
+ <a class="full_list_link" id="method_list_link"
51
+ href="../method_list.html">
52
+ Method List
53
+ </a>
54
+
55
+ <a class="full_list_link" id="file_list_link"
56
+ href="../file_list.html">
57
+ File List
58
+ </a>
59
+
60
+ </div>
61
+ <div class="clear"></div>
62
+ </div>
63
+
64
+ <iframe id="search_frame"></iframe>
65
+
66
+ <div id="content"><h1>Module: Mbrao::ParserInterface
67
+
68
+
69
+
70
+ </h1>
71
+
72
+ <dl class="box">
73
+
74
+
75
+
76
+ <dt class="r1">Extended by:</dt>
77
+ <dd class="r1">ActiveSupport::Concern</dd>
78
+
79
+
80
+
81
+
82
+
83
+
84
+ <dt class="r2">Included in:</dt>
85
+ <dd class="r2"><span class='object_link'><a href="Parser.html" title="Mbrao::Parser (class)">Parser</a></span></dd>
86
+
87
+
88
+
89
+ <dt class="r1 last">Defined in:</dt>
90
+ <dd class="r1 last">lib/mbrao/parser_interface.rb</dd>
91
+
92
+ </dl>
93
+ <div class="clear"></div>
94
+
95
+ <h2>Overview</h2><div class="docstring">
96
+ <div class="discussion">
97
+ <p>Methods to allow class level access.</p>
98
+
99
+
100
+ </div>
101
+ </div>
102
+ <div class="tags">
103
+
104
+
105
+ </div><h2>Defined Under Namespace</h2>
106
+ <p class="children">
107
+
108
+
109
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="ParserInterface/ClassMethods.html" title="Mbrao::ParserInterface::ClassMethods (module)">ClassMethods</a></span>
110
+
111
+
112
+
113
+
114
+ </p>
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+
123
+
124
+
125
+ </div>
126
+
127
+ <div id="footer">
128
+ Generated on Sun May 11 18:17:17 2014 by
129
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
130
+ 0.8.7.4 (ruby-2.1.0).
131
+ </div>
132
+
133
+ </body>
134
+ </html>
@@ -0,0 +1,1724 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Module: Mbrao::ParserInterface::ClassMethods
8
+
9
+ &mdash; Documentation by YARD 0.8.7.4
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../../css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../../css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ hasFrames = window.top.frames.main ? true : false;
19
+ relpath = '../../';
20
+ framesUrl = "../../frames.html#!Mbrao/ParserInterface/ClassMethods.html";
21
+ </script>
22
+
23
+
24
+ <script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
25
+
26
+ <script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
27
+
28
+
29
+ </head>
30
+ <body>
31
+ <div id="header">
32
+ <div id="menu">
33
+
34
+ <a href="../../_index.html">Index (C)</a> &raquo;
35
+ <span class='title'><span class='object_link'><a href="../../Mbrao.html" title="Mbrao (module)">Mbrao</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../ParserInterface.html" title="Mbrao::ParserInterface (module)">ParserInterface</a></span></span>
36
+ &raquo;
37
+ <span class="title">ClassMethods</span>
38
+
39
+
40
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41
+ </div>
42
+
43
+ <div id="search">
44
+
45
+ <a class="full_list_link" id="class_list_link"
46
+ href="../../class_list.html">
47
+ Class List
48
+ </a>
49
+
50
+ <a class="full_list_link" id="method_list_link"
51
+ href="../../method_list.html">
52
+ Method List
53
+ </a>
54
+
55
+ <a class="full_list_link" id="file_list_link"
56
+ href="../../file_list.html">
57
+ File List
58
+ </a>
59
+
60
+ </div>
61
+ <div class="clear"></div>
62
+ </div>
63
+
64
+ <iframe id="search_frame"></iframe>
65
+
66
+ <div id="content"><h1>Module: Mbrao::ParserInterface::ClassMethods
67
+
68
+
69
+
70
+ </h1>
71
+
72
+ <dl class="box">
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+ <dt class="r1 last">Defined in:</dt>
82
+ <dd class="r1 last">lib/mbrao/parser_interface.rb</dd>
83
+
84
+ </dl>
85
+ <div class="clear"></div>
86
+
87
+ <h2>Overview</h2><div class="docstring">
88
+ <div class="discussion">
89
+ <p>Class methods.</p>
90
+
91
+
92
+ </div>
93
+ </div>
94
+ <div class="tags">
95
+
96
+
97
+ </div>
98
+
99
+
100
+
101
+ <h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
102
+ <ul class="summary">
103
+
104
+ <li class="public ">
105
+ <span class="summary_signature">
106
+
107
+ <a href="#locale-instance_method" title="#locale (instance method)">- (String) <strong>locale</strong> </a>
108
+
109
+
110
+
111
+ </span>
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+
123
+
124
+ <span class="summary_desc"><div class='inline'><p>Gets the default locale for mbrao.</p>
125
+ </div></span>
126
+
127
+ </li>
128
+
129
+
130
+ <li class="public ">
131
+ <span class="summary_signature">
132
+
133
+ <a href="#parsing_engine-instance_method" title="#parsing_engine (instance method)">- (String) <strong>parsing_engine</strong> </a>
134
+
135
+
136
+
137
+ </span>
138
+
139
+
140
+
141
+
142
+
143
+
144
+
145
+
146
+
147
+
148
+
149
+
150
+ <span class="summary_desc"><div class='inline'><p>Gets the default parsing engine.</p>
151
+ </div></span>
152
+
153
+ </li>
154
+
155
+
156
+ <li class="public ">
157
+ <span class="summary_signature">
158
+
159
+ <a href="#rendering_engine-instance_method" title="#rendering_engine (instance method)">- (String) <strong>rendering_engine</strong> </a>
160
+
161
+
162
+
163
+ </span>
164
+
165
+
166
+
167
+
168
+
169
+
170
+
171
+
172
+
173
+
174
+
175
+
176
+ <span class="summary_desc"><div class='inline'><p>Gets the default rendering engine.</p>
177
+ </div></span>
178
+
179
+ </li>
180
+
181
+
182
+ </ul>
183
+
184
+
185
+
186
+
187
+
188
+ <h2>
189
+ Instance Method Summary
190
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
191
+ </h2>
192
+
193
+ <ul class="summary">
194
+
195
+ <li class="public ">
196
+ <span class="summary_signature">
197
+
198
+ <a href="#as_json-instance_method" title="#as_json (instance method)">- (Hash) <strong>as_json</strong>(target, keys, options = {}) </a>
199
+
200
+
201
+
202
+ </span>
203
+
204
+
205
+
206
+
207
+
208
+
209
+
210
+
211
+
212
+ <span class="summary_desc"><div class='inline'><p>Returns an object as a JSON compatible hash.</p>
213
+ </div></span>
214
+
215
+ </li>
216
+
217
+
218
+ <li class="public ">
219
+ <span class="summary_signature">
220
+
221
+ <a href="#create_engine-instance_method" title="#create_engine (instance method)">- (Object) <strong>create_engine</strong>(cls, type = :parsing) </a>
222
+
223
+
224
+
225
+ </span>
226
+
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+
235
+ <span class="summary_desc"><div class='inline'><p>Instantiates a new engine for rendering or parsing.</p>
236
+ </div></span>
237
+
238
+ </li>
239
+
240
+
241
+ <li class="public ">
242
+ <span class="summary_signature">
243
+
244
+ <a href="#instance-instance_method" title="#instance (instance method)">- (Parser) <strong>instance</strong>(force = false) </a>
245
+
246
+
247
+
248
+ </span>
249
+
250
+
251
+
252
+
253
+
254
+
255
+
256
+
257
+
258
+ <span class="summary_desc"><div class='inline'><p>Returns a unique (singleton) instance of the parser.</p>
259
+ </div></span>
260
+
261
+ </li>
262
+
263
+
264
+ <li class="public ">
265
+ <span class="summary_signature">
266
+
267
+ <a href="#parse-instance_method" title="#parse (instance method)">- (Content) <strong>parse</strong>(content, options = {}) </a>
268
+
269
+
270
+
271
+ </span>
272
+
273
+
274
+
275
+
276
+
277
+
278
+
279
+
280
+
281
+ <span class="summary_desc"><div class='inline'><p>Parses a source text.</p>
282
+ </div></span>
283
+
284
+ </li>
285
+
286
+
287
+ <li class="public ">
288
+ <span class="summary_signature">
289
+
290
+ <a href="#render-instance_method" title="#render (instance method)">- (String) <strong>render</strong>(content, options = {}, context = {}) </a>
291
+
292
+
293
+
294
+ </span>
295
+
296
+
297
+
298
+
299
+
300
+
301
+
302
+
303
+
304
+ <span class="summary_desc"><div class='inline'><p>Renders a content.</p>
305
+ </div></span>
306
+
307
+ </li>
308
+
309
+
310
+ </ul>
311
+
312
+
313
+
314
+ <div id="instance_attr_details" class="attr_details">
315
+ <h2>Instance Attribute Details</h2>
316
+
317
+
318
+ <span id="locale=-instance_method"></span>
319
+ <div class="method_details first">
320
+ <h3 class="signature first" id="locale-instance_method">
321
+
322
+ - (<tt>String</tt>) <strong>locale</strong>
323
+
324
+
325
+
326
+
327
+
328
+ </h3><div class="docstring">
329
+ <div class="discussion">
330
+ <p>Gets the default locale for mbrao.</p>
331
+
332
+
333
+ </div>
334
+ </div>
335
+ <div class="tags">
336
+
337
+ <p class="tag_title">Returns:</p>
338
+ <ul class="return">
339
+
340
+ <li>
341
+
342
+
343
+ <span class='type'>(<tt>String</tt>)</span>
344
+
345
+
346
+
347
+ &mdash;
348
+ <div class='inline'><p>The default locale.</p>
349
+ </div>
350
+
351
+ </li>
352
+
353
+ </ul>
354
+
355
+ </div><table class="source_code">
356
+ <tr>
357
+ <td>
358
+ <pre class="lines">
359
+
360
+
361
+ 21
362
+ 22
363
+ 23
364
+ 24
365
+ 25
366
+ 26
367
+ 27
368
+ 28
369
+ 29
370
+ 30
371
+ 31
372
+ 32
373
+ 33
374
+ 34
375
+ 35
376
+ 36
377
+ 37
378
+ 38
379
+ 39
380
+ 40
381
+ 41
382
+ 42
383
+ 43
384
+ 44
385
+ 45
386
+ 46
387
+ 47
388
+ 48
389
+ 49
390
+ 50
391
+ 51
392
+ 52
393
+ 53
394
+ 54
395
+ 55
396
+ 56
397
+ 57
398
+ 58
399
+ 59
400
+ 60
401
+ 61
402
+ 62
403
+ 63
404
+ 64
405
+ 65
406
+ 66
407
+ 67
408
+ 68
409
+ 69
410
+ 70
411
+ 71
412
+ 72
413
+ 73
414
+ 74
415
+ 75
416
+ 76
417
+ 77
418
+ 78
419
+ 79
420
+ 80
421
+ 81
422
+ 82
423
+ 83
424
+ 84
425
+ 85
426
+ 86
427
+ 87
428
+ 88
429
+ 89
430
+ 90
431
+ 91
432
+ 92
433
+ 93
434
+ 94
435
+ 95
436
+ 96
437
+ 97
438
+ 98
439
+ 99
440
+ 100
441
+ 101
442
+ 102
443
+ 103
444
+ 104
445
+ 105
446
+ 106
447
+ 107
448
+ 108
449
+ 109
450
+ 110
451
+ 111
452
+ 112
453
+ 113
454
+ 114
455
+ 115
456
+ 116
457
+ 117
458
+ 118
459
+ 119
460
+ 120
461
+ 121
462
+ 122
463
+ 123
464
+ 124
465
+ 125
466
+ 126
467
+ 127
468
+ 128
469
+ 129
470
+ 130
471
+ 131
472
+ 132
473
+ 133
474
+ 134
475
+ 135
476
+ 136
477
+ 137
478
+ 138
479
+ 139
480
+ 140
481
+ 141</pre>
482
+ </td>
483
+ <td>
484
+ <pre class="code"><span class="info file"># File 'lib/mbrao/parser_interface.rb', line 21</span>
485
+
486
+ <span class='kw'>module</span> <span class='const'>ClassMethods</span>
487
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:locale</span>
488
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:parsing_engine</span>
489
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:rendering_engine</span>
490
+
491
+ <span class='comment'># Gets the default locale for mbrao.
492
+ </span> <span class='comment'>#
493
+ </span> <span class='comment'># @return [String] The default locale.
494
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_locale'>locale</span>
495
+ <span class='id identifier rubyid_attribute_or_default'>attribute_or_default</span><span class='lparen'>(</span><span class='ivar'>@locale</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>en</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
496
+ <span class='kw'>end</span>
497
+
498
+ <span class='comment'># Gets the default parsing engine.
499
+ </span> <span class='comment'>#
500
+ </span> <span class='comment'># @return [String] The default parsing engine.
501
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_parsing_engine'>parsing_engine</span>
502
+ <span class='id identifier rubyid_attribute_or_default'>attribute_or_default</span><span class='lparen'>(</span><span class='ivar'>@parsing_engine</span><span class='comma'>,</span> <span class='symbol'>:plain_text</span><span class='comma'>,</span> <span class='symbol'>:to_sym</span><span class='rparen'>)</span>
503
+ <span class='kw'>end</span>
504
+
505
+ <span class='comment'># Gets the default rendering engine.
506
+ </span> <span class='comment'>#
507
+ </span> <span class='comment'># @return [String] The default rendering engine.
508
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_rendering_engine'>rendering_engine</span>
509
+ <span class='id identifier rubyid_attribute_or_default'>attribute_or_default</span><span class='lparen'>(</span><span class='ivar'>@rendering_engine</span><span class='comma'>,</span> <span class='symbol'>:html_pipeline</span><span class='comma'>,</span> <span class='symbol'>:to_sym</span><span class='rparen'>)</span>
510
+ <span class='kw'>end</span>
511
+
512
+ <span class='comment'># Parses a source text.
513
+ </span> <span class='comment'>#
514
+ </span> <span class='comment'># @param content [Object] The content to parse.
515
+ </span> <span class='comment'># @param options [Hash] A list of options for parsing.
516
+ </span> <span class='comment'># @return [Content] The parsed data.
517
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
518
+ <span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
519
+ <span class='kw'>end</span>
520
+
521
+ <span class='comment'># Renders a content.
522
+ </span> <span class='comment'>#
523
+ </span> <span class='comment'># @param content [Content] The content to parse.
524
+ </span> <span class='comment'># @param options [Hash] A list of options for renderer.
525
+ </span> <span class='comment'># @param context [Hash] A context for rendering.
526
+ </span> <span class='comment'># @return [String] The rendered content.
527
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_render'>render</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='id identifier rubyid_context'>context</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
528
+ <span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_render'>render</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='id identifier rubyid_context'>context</span><span class='rparen'>)</span>
529
+ <span class='kw'>end</span>
530
+
531
+ <span class='comment'># Returns an object as a JSON compatible hash
532
+ </span> <span class='comment'>#
533
+ </span> <span class='comment'># @param target [Object] The target to serialize.
534
+ </span> <span class='comment'># @param keys [Array] The attributes to include in the serialization.
535
+ </span> <span class='comment'># @param options [Hash] Options to modify behavior of the serialization.
536
+ </span> <span class='comment'># The only supported value are:
537
+ </span> <span class='comment'>#
538
+ </span> <span class='comment'># * `:exclude`, an array of attributes to skip.
539
+ </span> <span class='comment'># * `:exclude_empty`, if to exclude nil values. Default is `false`.
540
+ </span> <span class='comment'># @return [Hash] An hash with all attributes.
541
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_as_json'>as_json</span><span class='lparen'>(</span><span class='id identifier rubyid_target'>target</span><span class='comma'>,</span> <span class='id identifier rubyid_keys'>keys</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
542
+ <span class='id identifier rubyid_include_empty'>include_empty</span> <span class='op'>=</span> <span class='op'>!</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:exclude_empty</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_to_boolean'>to_boolean</span>
543
+ <span class='id identifier rubyid_exclude'>exclude</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:exclude</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='kw'>nil</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span>
544
+ <span class='id identifier rubyid_keys'>keys</span> <span class='op'>=</span> <span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='kw'>nil</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span>
545
+
546
+ <span class='id identifier rubyid_map_to_json'>map_to_json</span><span class='lparen'>(</span><span class='id identifier rubyid_target'>target</span><span class='comma'>,</span> <span class='lparen'>(</span><span class='id identifier rubyid_keys'>keys</span> <span class='op'>-</span> <span class='id identifier rubyid_exclude'>exclude</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_include_empty'>include_empty</span><span class='rparen'>)</span>
547
+ <span class='kw'>end</span>
548
+
549
+ <span class='comment'># Instantiates a new engine for rendering or parsing.
550
+ </span> <span class='comment'>#
551
+ </span> <span class='comment'># @param cls [String|Symbol|Object] If a `String` or a `Symbol`, then it will be the class of the engine.
552
+ </span> <span class='comment'># @param type [Symbol] The type or engine. Can be `:parsing` or `:rendering`.
553
+ </span> <span class='comment'># @return [Object] A new engine.
554
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_create_engine'>create_engine</span><span class='lparen'>(</span><span class='id identifier rubyid_cls'>cls</span><span class='comma'>,</span> <span class='id identifier rubyid_type'>type</span> <span class='op'>=</span> <span class='symbol'>:parsing</span><span class='rparen'>)</span>
555
+ <span class='id identifier rubyid_type'>type</span> <span class='op'>=</span> <span class='symbol'>:parsing</span> <span class='kw'>if</span> <span class='id identifier rubyid_type'>type</span> <span class='op'>!=</span> <span class='symbol'>:rendering</span>
556
+ <span class='op'>::</span><span class='const'>Lazier</span><span class='period'>.</span><span class='id identifier rubyid_find_class'>find_class</span><span class='lparen'>(</span><span class='id identifier rubyid_cls'>cls</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>::Mbrao::</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_type'>type</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_classify'>classify</span><span class='embexpr_end'>}</span><span class='tstring_content'>Engines::%CLASS%</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
557
+ <span class='kw'>rescue</span> <span class='const'>NameError</span>
558
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Exceptions</span><span class='op'>::</span><span class='const'>UnknownEngine</span>
559
+ <span class='kw'>end</span>
560
+
561
+ <span class='comment'># Returns a unique (singleton) instance of the parser.
562
+ </span> <span class='comment'>#
563
+ </span> <span class='comment'># @param force [Boolean] If to force recreation of the instance.
564
+ </span> <span class='comment'># @return [Parser] The unique (singleton) instance of the parser.
565
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_instance'>instance</span><span class='lparen'>(</span><span class='id identifier rubyid_force'>force</span> <span class='op'>=</span> <span class='kw'>false</span><span class='rparen'>)</span>
566
+ <span class='ivar'>@instance</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_force'>force</span>
567
+ <span class='ivar'>@instance</span> <span class='op'>||=</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Parser</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
568
+ <span class='kw'>end</span>
569
+
570
+ <span class='id identifier rubyid_private'>private</span>
571
+
572
+ <span class='comment'># Returns an attribute or a default value.
573
+ </span> <span class='comment'>#
574
+ </span> <span class='comment'># @param attr [Object ]The attribute to return.
575
+ </span> <span class='comment'># @param default_value [Object] The value to return if `attr` is blank.
576
+ </span> <span class='comment'># @param sanitizer [Symbol] An optional method to sanitize the returned value.
577
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_attribute_or_default'>attribute_or_default</span><span class='lparen'>(</span><span class='id identifier rubyid_attr'>attr</span><span class='comma'>,</span> <span class='id identifier rubyid_default_value'>default_value</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_sanitizer'>sanitizer</span> <span class='op'>=</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span>
578
+ <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_attr'>attr</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>?</span> <span class='id identifier rubyid_attr'>attr</span> <span class='op'>:</span> <span class='id identifier rubyid_default_value'>default_value</span>
579
+ <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_rv'>rv</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_sanitizer'>sanitizer</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_sanitizer'>sanitizer</span>
580
+ <span class='id identifier rubyid_rv'>rv</span>
581
+ <span class='kw'>end</span>
582
+
583
+ <span class='comment'># Perform the mapping to JSON.
584
+ </span> <span class='comment'>#
585
+ </span> <span class='comment'># @param target [Object] The target to serialize.
586
+ </span> <span class='comment'># @param keys [Array] The attributes to include in the serialization.
587
+ </span> <span class='comment'># @param include_empty [Boolean], if to include nil values.
588
+ </span> <span class='comment'># @return [Hash] An hash with all attributes.
589
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_map_to_json'>map_to_json</span><span class='lparen'>(</span><span class='id identifier rubyid_target'>target</span><span class='comma'>,</span> <span class='id identifier rubyid_keys'>keys</span><span class='comma'>,</span> <span class='id identifier rubyid_include_empty'>include_empty</span><span class='rparen'>)</span>
590
+ <span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_reduce'>reduce</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_rv'>rv</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</span><span class='op'>|</span>
591
+ <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_get_json_field'>get_json_field</span><span class='lparen'>(</span><span class='id identifier rubyid_target'>target</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
592
+ <span class='id identifier rubyid_rv'>rv</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span> <span class='kw'>if</span> <span class='id identifier rubyid_include_empty'>include_empty</span> <span class='op'>||</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
593
+ <span class='id identifier rubyid_rv'>rv</span>
594
+ <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_deep_stringify_keys'>deep_stringify_keys</span>
595
+ <span class='kw'>end</span>
596
+
597
+ <span class='comment'># Get a field as JSON.
598
+ </span> <span class='comment'>#
599
+ </span> <span class='comment'># @param target [Object] The object containing the value.
600
+ </span> <span class='comment'># @param method [Symbol] The method containing the value.
601
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_get_json_field'>get_json_field</span><span class='lparen'>(</span><span class='id identifier rubyid_target'>target</span><span class='comma'>,</span> <span class='id identifier rubyid_method'>method</span><span class='rparen'>)</span>
602
+ <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_target'>target</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span><span class='rparen'>)</span>
603
+ <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_as_json'>as_json</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:as_json</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Symbol</span><span class='rparen'>)</span>
604
+ <span class='id identifier rubyid_value'>value</span>
605
+ <span class='kw'>end</span>
606
+ <span class='kw'>end</span></pre>
607
+ </td>
608
+ </tr>
609
+ </table>
610
+ </div>
611
+
612
+
613
+ <span id="parsing_engine=-instance_method"></span>
614
+ <div class="method_details ">
615
+ <h3 class="signature " id="parsing_engine-instance_method">
616
+
617
+ - (<tt>String</tt>) <strong>parsing_engine</strong>
618
+
619
+
620
+
621
+
622
+
623
+ </h3><div class="docstring">
624
+ <div class="discussion">
625
+ <p>Gets the default parsing engine.</p>
626
+
627
+
628
+ </div>
629
+ </div>
630
+ <div class="tags">
631
+
632
+ <p class="tag_title">Returns:</p>
633
+ <ul class="return">
634
+
635
+ <li>
636
+
637
+
638
+ <span class='type'>(<tt>String</tt>)</span>
639
+
640
+
641
+
642
+ &mdash;
643
+ <div class='inline'><p>The default parsing engine.</p>
644
+ </div>
645
+
646
+ </li>
647
+
648
+ </ul>
649
+
650
+ </div><table class="source_code">
651
+ <tr>
652
+ <td>
653
+ <pre class="lines">
654
+
655
+
656
+ 21
657
+ 22
658
+ 23
659
+ 24
660
+ 25
661
+ 26
662
+ 27
663
+ 28
664
+ 29
665
+ 30
666
+ 31
667
+ 32
668
+ 33
669
+ 34
670
+ 35
671
+ 36
672
+ 37
673
+ 38
674
+ 39
675
+ 40
676
+ 41
677
+ 42
678
+ 43
679
+ 44
680
+ 45
681
+ 46
682
+ 47
683
+ 48
684
+ 49
685
+ 50
686
+ 51
687
+ 52
688
+ 53
689
+ 54
690
+ 55
691
+ 56
692
+ 57
693
+ 58
694
+ 59
695
+ 60
696
+ 61
697
+ 62
698
+ 63
699
+ 64
700
+ 65
701
+ 66
702
+ 67
703
+ 68
704
+ 69
705
+ 70
706
+ 71
707
+ 72
708
+ 73
709
+ 74
710
+ 75
711
+ 76
712
+ 77
713
+ 78
714
+ 79
715
+ 80
716
+ 81
717
+ 82
718
+ 83
719
+ 84
720
+ 85
721
+ 86
722
+ 87
723
+ 88
724
+ 89
725
+ 90
726
+ 91
727
+ 92
728
+ 93
729
+ 94
730
+ 95
731
+ 96
732
+ 97
733
+ 98
734
+ 99
735
+ 100
736
+ 101
737
+ 102
738
+ 103
739
+ 104
740
+ 105
741
+ 106
742
+ 107
743
+ 108
744
+ 109
745
+ 110
746
+ 111
747
+ 112
748
+ 113
749
+ 114
750
+ 115
751
+ 116
752
+ 117
753
+ 118
754
+ 119
755
+ 120
756
+ 121
757
+ 122
758
+ 123
759
+ 124
760
+ 125
761
+ 126
762
+ 127
763
+ 128
764
+ 129
765
+ 130
766
+ 131
767
+ 132
768
+ 133
769
+ 134
770
+ 135
771
+ 136
772
+ 137
773
+ 138
774
+ 139
775
+ 140
776
+ 141</pre>
777
+ </td>
778
+ <td>
779
+ <pre class="code"><span class="info file"># File 'lib/mbrao/parser_interface.rb', line 21</span>
780
+
781
+ <span class='kw'>module</span> <span class='const'>ClassMethods</span>
782
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:locale</span>
783
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:parsing_engine</span>
784
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:rendering_engine</span>
785
+
786
+ <span class='comment'># Gets the default locale for mbrao.
787
+ </span> <span class='comment'>#
788
+ </span> <span class='comment'># @return [String] The default locale.
789
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_locale'>locale</span>
790
+ <span class='id identifier rubyid_attribute_or_default'>attribute_or_default</span><span class='lparen'>(</span><span class='ivar'>@locale</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>en</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
791
+ <span class='kw'>end</span>
792
+
793
+ <span class='comment'># Gets the default parsing engine.
794
+ </span> <span class='comment'>#
795
+ </span> <span class='comment'># @return [String] The default parsing engine.
796
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_parsing_engine'>parsing_engine</span>
797
+ <span class='id identifier rubyid_attribute_or_default'>attribute_or_default</span><span class='lparen'>(</span><span class='ivar'>@parsing_engine</span><span class='comma'>,</span> <span class='symbol'>:plain_text</span><span class='comma'>,</span> <span class='symbol'>:to_sym</span><span class='rparen'>)</span>
798
+ <span class='kw'>end</span>
799
+
800
+ <span class='comment'># Gets the default rendering engine.
801
+ </span> <span class='comment'>#
802
+ </span> <span class='comment'># @return [String] The default rendering engine.
803
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_rendering_engine'>rendering_engine</span>
804
+ <span class='id identifier rubyid_attribute_or_default'>attribute_or_default</span><span class='lparen'>(</span><span class='ivar'>@rendering_engine</span><span class='comma'>,</span> <span class='symbol'>:html_pipeline</span><span class='comma'>,</span> <span class='symbol'>:to_sym</span><span class='rparen'>)</span>
805
+ <span class='kw'>end</span>
806
+
807
+ <span class='comment'># Parses a source text.
808
+ </span> <span class='comment'>#
809
+ </span> <span class='comment'># @param content [Object] The content to parse.
810
+ </span> <span class='comment'># @param options [Hash] A list of options for parsing.
811
+ </span> <span class='comment'># @return [Content] The parsed data.
812
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
813
+ <span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
814
+ <span class='kw'>end</span>
815
+
816
+ <span class='comment'># Renders a content.
817
+ </span> <span class='comment'>#
818
+ </span> <span class='comment'># @param content [Content] The content to parse.
819
+ </span> <span class='comment'># @param options [Hash] A list of options for renderer.
820
+ </span> <span class='comment'># @param context [Hash] A context for rendering.
821
+ </span> <span class='comment'># @return [String] The rendered content.
822
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_render'>render</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='id identifier rubyid_context'>context</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
823
+ <span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_render'>render</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='id identifier rubyid_context'>context</span><span class='rparen'>)</span>
824
+ <span class='kw'>end</span>
825
+
826
+ <span class='comment'># Returns an object as a JSON compatible hash
827
+ </span> <span class='comment'>#
828
+ </span> <span class='comment'># @param target [Object] The target to serialize.
829
+ </span> <span class='comment'># @param keys [Array] The attributes to include in the serialization.
830
+ </span> <span class='comment'># @param options [Hash] Options to modify behavior of the serialization.
831
+ </span> <span class='comment'># The only supported value are:
832
+ </span> <span class='comment'>#
833
+ </span> <span class='comment'># * `:exclude`, an array of attributes to skip.
834
+ </span> <span class='comment'># * `:exclude_empty`, if to exclude nil values. Default is `false`.
835
+ </span> <span class='comment'># @return [Hash] An hash with all attributes.
836
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_as_json'>as_json</span><span class='lparen'>(</span><span class='id identifier rubyid_target'>target</span><span class='comma'>,</span> <span class='id identifier rubyid_keys'>keys</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
837
+ <span class='id identifier rubyid_include_empty'>include_empty</span> <span class='op'>=</span> <span class='op'>!</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:exclude_empty</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_to_boolean'>to_boolean</span>
838
+ <span class='id identifier rubyid_exclude'>exclude</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:exclude</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='kw'>nil</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span>
839
+ <span class='id identifier rubyid_keys'>keys</span> <span class='op'>=</span> <span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='kw'>nil</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span>
840
+
841
+ <span class='id identifier rubyid_map_to_json'>map_to_json</span><span class='lparen'>(</span><span class='id identifier rubyid_target'>target</span><span class='comma'>,</span> <span class='lparen'>(</span><span class='id identifier rubyid_keys'>keys</span> <span class='op'>-</span> <span class='id identifier rubyid_exclude'>exclude</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_include_empty'>include_empty</span><span class='rparen'>)</span>
842
+ <span class='kw'>end</span>
843
+
844
+ <span class='comment'># Instantiates a new engine for rendering or parsing.
845
+ </span> <span class='comment'>#
846
+ </span> <span class='comment'># @param cls [String|Symbol|Object] If a `String` or a `Symbol`, then it will be the class of the engine.
847
+ </span> <span class='comment'># @param type [Symbol] The type or engine. Can be `:parsing` or `:rendering`.
848
+ </span> <span class='comment'># @return [Object] A new engine.
849
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_create_engine'>create_engine</span><span class='lparen'>(</span><span class='id identifier rubyid_cls'>cls</span><span class='comma'>,</span> <span class='id identifier rubyid_type'>type</span> <span class='op'>=</span> <span class='symbol'>:parsing</span><span class='rparen'>)</span>
850
+ <span class='id identifier rubyid_type'>type</span> <span class='op'>=</span> <span class='symbol'>:parsing</span> <span class='kw'>if</span> <span class='id identifier rubyid_type'>type</span> <span class='op'>!=</span> <span class='symbol'>:rendering</span>
851
+ <span class='op'>::</span><span class='const'>Lazier</span><span class='period'>.</span><span class='id identifier rubyid_find_class'>find_class</span><span class='lparen'>(</span><span class='id identifier rubyid_cls'>cls</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>::Mbrao::</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_type'>type</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_classify'>classify</span><span class='embexpr_end'>}</span><span class='tstring_content'>Engines::%CLASS%</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
852
+ <span class='kw'>rescue</span> <span class='const'>NameError</span>
853
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Exceptions</span><span class='op'>::</span><span class='const'>UnknownEngine</span>
854
+ <span class='kw'>end</span>
855
+
856
+ <span class='comment'># Returns a unique (singleton) instance of the parser.
857
+ </span> <span class='comment'>#
858
+ </span> <span class='comment'># @param force [Boolean] If to force recreation of the instance.
859
+ </span> <span class='comment'># @return [Parser] The unique (singleton) instance of the parser.
860
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_instance'>instance</span><span class='lparen'>(</span><span class='id identifier rubyid_force'>force</span> <span class='op'>=</span> <span class='kw'>false</span><span class='rparen'>)</span>
861
+ <span class='ivar'>@instance</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_force'>force</span>
862
+ <span class='ivar'>@instance</span> <span class='op'>||=</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Parser</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
863
+ <span class='kw'>end</span>
864
+
865
+ <span class='id identifier rubyid_private'>private</span>
866
+
867
+ <span class='comment'># Returns an attribute or a default value.
868
+ </span> <span class='comment'>#
869
+ </span> <span class='comment'># @param attr [Object ]The attribute to return.
870
+ </span> <span class='comment'># @param default_value [Object] The value to return if `attr` is blank.
871
+ </span> <span class='comment'># @param sanitizer [Symbol] An optional method to sanitize the returned value.
872
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_attribute_or_default'>attribute_or_default</span><span class='lparen'>(</span><span class='id identifier rubyid_attr'>attr</span><span class='comma'>,</span> <span class='id identifier rubyid_default_value'>default_value</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_sanitizer'>sanitizer</span> <span class='op'>=</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span>
873
+ <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_attr'>attr</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>?</span> <span class='id identifier rubyid_attr'>attr</span> <span class='op'>:</span> <span class='id identifier rubyid_default_value'>default_value</span>
874
+ <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_rv'>rv</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_sanitizer'>sanitizer</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_sanitizer'>sanitizer</span>
875
+ <span class='id identifier rubyid_rv'>rv</span>
876
+ <span class='kw'>end</span>
877
+
878
+ <span class='comment'># Perform the mapping to JSON.
879
+ </span> <span class='comment'>#
880
+ </span> <span class='comment'># @param target [Object] The target to serialize.
881
+ </span> <span class='comment'># @param keys [Array] The attributes to include in the serialization.
882
+ </span> <span class='comment'># @param include_empty [Boolean], if to include nil values.
883
+ </span> <span class='comment'># @return [Hash] An hash with all attributes.
884
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_map_to_json'>map_to_json</span><span class='lparen'>(</span><span class='id identifier rubyid_target'>target</span><span class='comma'>,</span> <span class='id identifier rubyid_keys'>keys</span><span class='comma'>,</span> <span class='id identifier rubyid_include_empty'>include_empty</span><span class='rparen'>)</span>
885
+ <span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_reduce'>reduce</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_rv'>rv</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</span><span class='op'>|</span>
886
+ <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_get_json_field'>get_json_field</span><span class='lparen'>(</span><span class='id identifier rubyid_target'>target</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
887
+ <span class='id identifier rubyid_rv'>rv</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span> <span class='kw'>if</span> <span class='id identifier rubyid_include_empty'>include_empty</span> <span class='op'>||</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
888
+ <span class='id identifier rubyid_rv'>rv</span>
889
+ <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_deep_stringify_keys'>deep_stringify_keys</span>
890
+ <span class='kw'>end</span>
891
+
892
+ <span class='comment'># Get a field as JSON.
893
+ </span> <span class='comment'>#
894
+ </span> <span class='comment'># @param target [Object] The object containing the value.
895
+ </span> <span class='comment'># @param method [Symbol] The method containing the value.
896
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_get_json_field'>get_json_field</span><span class='lparen'>(</span><span class='id identifier rubyid_target'>target</span><span class='comma'>,</span> <span class='id identifier rubyid_method'>method</span><span class='rparen'>)</span>
897
+ <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_target'>target</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span><span class='rparen'>)</span>
898
+ <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_as_json'>as_json</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:as_json</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Symbol</span><span class='rparen'>)</span>
899
+ <span class='id identifier rubyid_value'>value</span>
900
+ <span class='kw'>end</span>
901
+ <span class='kw'>end</span></pre>
902
+ </td>
903
+ </tr>
904
+ </table>
905
+ </div>
906
+
907
+
908
+ <span id="rendering_engine=-instance_method"></span>
909
+ <div class="method_details ">
910
+ <h3 class="signature " id="rendering_engine-instance_method">
911
+
912
+ - (<tt>String</tt>) <strong>rendering_engine</strong>
913
+
914
+
915
+
916
+
917
+
918
+ </h3><div class="docstring">
919
+ <div class="discussion">
920
+ <p>Gets the default rendering engine.</p>
921
+
922
+
923
+ </div>
924
+ </div>
925
+ <div class="tags">
926
+
927
+ <p class="tag_title">Returns:</p>
928
+ <ul class="return">
929
+
930
+ <li>
931
+
932
+
933
+ <span class='type'>(<tt>String</tt>)</span>
934
+
935
+
936
+
937
+ &mdash;
938
+ <div class='inline'><p>The default rendering engine.</p>
939
+ </div>
940
+
941
+ </li>
942
+
943
+ </ul>
944
+
945
+ </div><table class="source_code">
946
+ <tr>
947
+ <td>
948
+ <pre class="lines">
949
+
950
+
951
+ 21
952
+ 22
953
+ 23
954
+ 24
955
+ 25
956
+ 26
957
+ 27
958
+ 28
959
+ 29
960
+ 30
961
+ 31
962
+ 32
963
+ 33
964
+ 34
965
+ 35
966
+ 36
967
+ 37
968
+ 38
969
+ 39
970
+ 40
971
+ 41
972
+ 42
973
+ 43
974
+ 44
975
+ 45
976
+ 46
977
+ 47
978
+ 48
979
+ 49
980
+ 50
981
+ 51
982
+ 52
983
+ 53
984
+ 54
985
+ 55
986
+ 56
987
+ 57
988
+ 58
989
+ 59
990
+ 60
991
+ 61
992
+ 62
993
+ 63
994
+ 64
995
+ 65
996
+ 66
997
+ 67
998
+ 68
999
+ 69
1000
+ 70
1001
+ 71
1002
+ 72
1003
+ 73
1004
+ 74
1005
+ 75
1006
+ 76
1007
+ 77
1008
+ 78
1009
+ 79
1010
+ 80
1011
+ 81
1012
+ 82
1013
+ 83
1014
+ 84
1015
+ 85
1016
+ 86
1017
+ 87
1018
+ 88
1019
+ 89
1020
+ 90
1021
+ 91
1022
+ 92
1023
+ 93
1024
+ 94
1025
+ 95
1026
+ 96
1027
+ 97
1028
+ 98
1029
+ 99
1030
+ 100
1031
+ 101
1032
+ 102
1033
+ 103
1034
+ 104
1035
+ 105
1036
+ 106
1037
+ 107
1038
+ 108
1039
+ 109
1040
+ 110
1041
+ 111
1042
+ 112
1043
+ 113
1044
+ 114
1045
+ 115
1046
+ 116
1047
+ 117
1048
+ 118
1049
+ 119
1050
+ 120
1051
+ 121
1052
+ 122
1053
+ 123
1054
+ 124
1055
+ 125
1056
+ 126
1057
+ 127
1058
+ 128
1059
+ 129
1060
+ 130
1061
+ 131
1062
+ 132
1063
+ 133
1064
+ 134
1065
+ 135
1066
+ 136
1067
+ 137
1068
+ 138
1069
+ 139
1070
+ 140
1071
+ 141</pre>
1072
+ </td>
1073
+ <td>
1074
+ <pre class="code"><span class="info file"># File 'lib/mbrao/parser_interface.rb', line 21</span>
1075
+
1076
+ <span class='kw'>module</span> <span class='const'>ClassMethods</span>
1077
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:locale</span>
1078
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:parsing_engine</span>
1079
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:rendering_engine</span>
1080
+
1081
+ <span class='comment'># Gets the default locale for mbrao.
1082
+ </span> <span class='comment'>#
1083
+ </span> <span class='comment'># @return [String] The default locale.
1084
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_locale'>locale</span>
1085
+ <span class='id identifier rubyid_attribute_or_default'>attribute_or_default</span><span class='lparen'>(</span><span class='ivar'>@locale</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>en</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
1086
+ <span class='kw'>end</span>
1087
+
1088
+ <span class='comment'># Gets the default parsing engine.
1089
+ </span> <span class='comment'>#
1090
+ </span> <span class='comment'># @return [String] The default parsing engine.
1091
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_parsing_engine'>parsing_engine</span>
1092
+ <span class='id identifier rubyid_attribute_or_default'>attribute_or_default</span><span class='lparen'>(</span><span class='ivar'>@parsing_engine</span><span class='comma'>,</span> <span class='symbol'>:plain_text</span><span class='comma'>,</span> <span class='symbol'>:to_sym</span><span class='rparen'>)</span>
1093
+ <span class='kw'>end</span>
1094
+
1095
+ <span class='comment'># Gets the default rendering engine.
1096
+ </span> <span class='comment'>#
1097
+ </span> <span class='comment'># @return [String] The default rendering engine.
1098
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_rendering_engine'>rendering_engine</span>
1099
+ <span class='id identifier rubyid_attribute_or_default'>attribute_or_default</span><span class='lparen'>(</span><span class='ivar'>@rendering_engine</span><span class='comma'>,</span> <span class='symbol'>:html_pipeline</span><span class='comma'>,</span> <span class='symbol'>:to_sym</span><span class='rparen'>)</span>
1100
+ <span class='kw'>end</span>
1101
+
1102
+ <span class='comment'># Parses a source text.
1103
+ </span> <span class='comment'>#
1104
+ </span> <span class='comment'># @param content [Object] The content to parse.
1105
+ </span> <span class='comment'># @param options [Hash] A list of options for parsing.
1106
+ </span> <span class='comment'># @return [Content] The parsed data.
1107
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
1108
+ <span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
1109
+ <span class='kw'>end</span>
1110
+
1111
+ <span class='comment'># Renders a content.
1112
+ </span> <span class='comment'>#
1113
+ </span> <span class='comment'># @param content [Content] The content to parse.
1114
+ </span> <span class='comment'># @param options [Hash] A list of options for renderer.
1115
+ </span> <span class='comment'># @param context [Hash] A context for rendering.
1116
+ </span> <span class='comment'># @return [String] The rendered content.
1117
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_render'>render</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='id identifier rubyid_context'>context</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
1118
+ <span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_render'>render</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='id identifier rubyid_context'>context</span><span class='rparen'>)</span>
1119
+ <span class='kw'>end</span>
1120
+
1121
+ <span class='comment'># Returns an object as a JSON compatible hash
1122
+ </span> <span class='comment'>#
1123
+ </span> <span class='comment'># @param target [Object] The target to serialize.
1124
+ </span> <span class='comment'># @param keys [Array] The attributes to include in the serialization.
1125
+ </span> <span class='comment'># @param options [Hash] Options to modify behavior of the serialization.
1126
+ </span> <span class='comment'># The only supported value are:
1127
+ </span> <span class='comment'>#
1128
+ </span> <span class='comment'># * `:exclude`, an array of attributes to skip.
1129
+ </span> <span class='comment'># * `:exclude_empty`, if to exclude nil values. Default is `false`.
1130
+ </span> <span class='comment'># @return [Hash] An hash with all attributes.
1131
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_as_json'>as_json</span><span class='lparen'>(</span><span class='id identifier rubyid_target'>target</span><span class='comma'>,</span> <span class='id identifier rubyid_keys'>keys</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
1132
+ <span class='id identifier rubyid_include_empty'>include_empty</span> <span class='op'>=</span> <span class='op'>!</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:exclude_empty</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_to_boolean'>to_boolean</span>
1133
+ <span class='id identifier rubyid_exclude'>exclude</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:exclude</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='kw'>nil</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span>
1134
+ <span class='id identifier rubyid_keys'>keys</span> <span class='op'>=</span> <span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='kw'>nil</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span>
1135
+
1136
+ <span class='id identifier rubyid_map_to_json'>map_to_json</span><span class='lparen'>(</span><span class='id identifier rubyid_target'>target</span><span class='comma'>,</span> <span class='lparen'>(</span><span class='id identifier rubyid_keys'>keys</span> <span class='op'>-</span> <span class='id identifier rubyid_exclude'>exclude</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_include_empty'>include_empty</span><span class='rparen'>)</span>
1137
+ <span class='kw'>end</span>
1138
+
1139
+ <span class='comment'># Instantiates a new engine for rendering or parsing.
1140
+ </span> <span class='comment'>#
1141
+ </span> <span class='comment'># @param cls [String|Symbol|Object] If a `String` or a `Symbol`, then it will be the class of the engine.
1142
+ </span> <span class='comment'># @param type [Symbol] The type or engine. Can be `:parsing` or `:rendering`.
1143
+ </span> <span class='comment'># @return [Object] A new engine.
1144
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_create_engine'>create_engine</span><span class='lparen'>(</span><span class='id identifier rubyid_cls'>cls</span><span class='comma'>,</span> <span class='id identifier rubyid_type'>type</span> <span class='op'>=</span> <span class='symbol'>:parsing</span><span class='rparen'>)</span>
1145
+ <span class='id identifier rubyid_type'>type</span> <span class='op'>=</span> <span class='symbol'>:parsing</span> <span class='kw'>if</span> <span class='id identifier rubyid_type'>type</span> <span class='op'>!=</span> <span class='symbol'>:rendering</span>
1146
+ <span class='op'>::</span><span class='const'>Lazier</span><span class='period'>.</span><span class='id identifier rubyid_find_class'>find_class</span><span class='lparen'>(</span><span class='id identifier rubyid_cls'>cls</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>::Mbrao::</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_type'>type</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_classify'>classify</span><span class='embexpr_end'>}</span><span class='tstring_content'>Engines::%CLASS%</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
1147
+ <span class='kw'>rescue</span> <span class='const'>NameError</span>
1148
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Exceptions</span><span class='op'>::</span><span class='const'>UnknownEngine</span>
1149
+ <span class='kw'>end</span>
1150
+
1151
+ <span class='comment'># Returns a unique (singleton) instance of the parser.
1152
+ </span> <span class='comment'>#
1153
+ </span> <span class='comment'># @param force [Boolean] If to force recreation of the instance.
1154
+ </span> <span class='comment'># @return [Parser] The unique (singleton) instance of the parser.
1155
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_instance'>instance</span><span class='lparen'>(</span><span class='id identifier rubyid_force'>force</span> <span class='op'>=</span> <span class='kw'>false</span><span class='rparen'>)</span>
1156
+ <span class='ivar'>@instance</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_force'>force</span>
1157
+ <span class='ivar'>@instance</span> <span class='op'>||=</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Parser</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
1158
+ <span class='kw'>end</span>
1159
+
1160
+ <span class='id identifier rubyid_private'>private</span>
1161
+
1162
+ <span class='comment'># Returns an attribute or a default value.
1163
+ </span> <span class='comment'>#
1164
+ </span> <span class='comment'># @param attr [Object ]The attribute to return.
1165
+ </span> <span class='comment'># @param default_value [Object] The value to return if `attr` is blank.
1166
+ </span> <span class='comment'># @param sanitizer [Symbol] An optional method to sanitize the returned value.
1167
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_attribute_or_default'>attribute_or_default</span><span class='lparen'>(</span><span class='id identifier rubyid_attr'>attr</span><span class='comma'>,</span> <span class='id identifier rubyid_default_value'>default_value</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_sanitizer'>sanitizer</span> <span class='op'>=</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span>
1168
+ <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_attr'>attr</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>?</span> <span class='id identifier rubyid_attr'>attr</span> <span class='op'>:</span> <span class='id identifier rubyid_default_value'>default_value</span>
1169
+ <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_rv'>rv</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_sanitizer'>sanitizer</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_sanitizer'>sanitizer</span>
1170
+ <span class='id identifier rubyid_rv'>rv</span>
1171
+ <span class='kw'>end</span>
1172
+
1173
+ <span class='comment'># Perform the mapping to JSON.
1174
+ </span> <span class='comment'>#
1175
+ </span> <span class='comment'># @param target [Object] The target to serialize.
1176
+ </span> <span class='comment'># @param keys [Array] The attributes to include in the serialization.
1177
+ </span> <span class='comment'># @param include_empty [Boolean], if to include nil values.
1178
+ </span> <span class='comment'># @return [Hash] An hash with all attributes.
1179
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_map_to_json'>map_to_json</span><span class='lparen'>(</span><span class='id identifier rubyid_target'>target</span><span class='comma'>,</span> <span class='id identifier rubyid_keys'>keys</span><span class='comma'>,</span> <span class='id identifier rubyid_include_empty'>include_empty</span><span class='rparen'>)</span>
1180
+ <span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_reduce'>reduce</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_rv'>rv</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</span><span class='op'>|</span>
1181
+ <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_get_json_field'>get_json_field</span><span class='lparen'>(</span><span class='id identifier rubyid_target'>target</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
1182
+ <span class='id identifier rubyid_rv'>rv</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span> <span class='kw'>if</span> <span class='id identifier rubyid_include_empty'>include_empty</span> <span class='op'>||</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
1183
+ <span class='id identifier rubyid_rv'>rv</span>
1184
+ <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_deep_stringify_keys'>deep_stringify_keys</span>
1185
+ <span class='kw'>end</span>
1186
+
1187
+ <span class='comment'># Get a field as JSON.
1188
+ </span> <span class='comment'>#
1189
+ </span> <span class='comment'># @param target [Object] The object containing the value.
1190
+ </span> <span class='comment'># @param method [Symbol] The method containing the value.
1191
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_get_json_field'>get_json_field</span><span class='lparen'>(</span><span class='id identifier rubyid_target'>target</span><span class='comma'>,</span> <span class='id identifier rubyid_method'>method</span><span class='rparen'>)</span>
1192
+ <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_target'>target</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span><span class='rparen'>)</span>
1193
+ <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_as_json'>as_json</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:as_json</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Symbol</span><span class='rparen'>)</span>
1194
+ <span class='id identifier rubyid_value'>value</span>
1195
+ <span class='kw'>end</span>
1196
+ <span class='kw'>end</span></pre>
1197
+ </td>
1198
+ </tr>
1199
+ </table>
1200
+ </div>
1201
+
1202
+ </div>
1203
+
1204
+
1205
+ <div id="instance_method_details" class="method_details_list">
1206
+ <h2>Instance Method Details</h2>
1207
+
1208
+
1209
+ <div class="method_details first">
1210
+ <h3 class="signature first" id="as_json-instance_method">
1211
+
1212
+ - (<tt>Hash</tt>) <strong>as_json</strong>(target, keys, options = {})
1213
+
1214
+
1215
+
1216
+
1217
+
1218
+ </h3><div class="docstring">
1219
+ <div class="discussion">
1220
+ <p>Returns an object as a JSON compatible hash</p>
1221
+
1222
+
1223
+ </div>
1224
+ </div>
1225
+ <div class="tags">
1226
+ <p class="tag_title">Parameters:</p>
1227
+ <ul class="param">
1228
+
1229
+ <li>
1230
+
1231
+ <span class='name'>target</span>
1232
+
1233
+
1234
+ <span class='type'>(<tt>Object</tt>)</span>
1235
+
1236
+
1237
+
1238
+ &mdash;
1239
+ <div class='inline'><p>The target to serialize.</p>
1240
+ </div>
1241
+
1242
+ </li>
1243
+
1244
+ <li>
1245
+
1246
+ <span class='name'>keys</span>
1247
+
1248
+
1249
+ <span class='type'>(<tt>Array</tt>)</span>
1250
+
1251
+
1252
+
1253
+ &mdash;
1254
+ <div class='inline'><p>The attributes to include in the serialization.</p>
1255
+ </div>
1256
+
1257
+ </li>
1258
+
1259
+ <li>
1260
+
1261
+ <span class='name'>options</span>
1262
+
1263
+
1264
+ <span class='type'>(<tt>Hash</tt>)</span>
1265
+
1266
+
1267
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
1268
+
1269
+
1270
+ &mdash;
1271
+ <div class='inline'><p>Options to modify behavior of the serialization.
1272
+ The only supported value are:</p>
1273
+
1274
+ <ul>
1275
+ <li><code>:exclude</code>, an array of attributes to skip.</li>
1276
+ <li><code>:exclude_empty</code>, if to exclude nil values. Default is <code>false</code>.</li>
1277
+ </ul>
1278
+ </div>
1279
+
1280
+ </li>
1281
+
1282
+ </ul>
1283
+
1284
+ <p class="tag_title">Returns:</p>
1285
+ <ul class="return">
1286
+
1287
+ <li>
1288
+
1289
+
1290
+ <span class='type'>(<tt>Hash</tt>)</span>
1291
+
1292
+
1293
+
1294
+ &mdash;
1295
+ <div class='inline'><p>An hash with all attributes.</p>
1296
+ </div>
1297
+
1298
+ </li>
1299
+
1300
+ </ul>
1301
+
1302
+ </div><table class="source_code">
1303
+ <tr>
1304
+ <td>
1305
+ <pre class="lines">
1306
+
1307
+
1308
+ 76
1309
+ 77
1310
+ 78
1311
+ 79
1312
+ 80
1313
+ 81
1314
+ 82</pre>
1315
+ </td>
1316
+ <td>
1317
+ <pre class="code"><span class="info file"># File 'lib/mbrao/parser_interface.rb', line 76</span>
1318
+
1319
+ <span class='kw'>def</span> <span class='id identifier rubyid_as_json'>as_json</span><span class='lparen'>(</span><span class='id identifier rubyid_target'>target</span><span class='comma'>,</span> <span class='id identifier rubyid_keys'>keys</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
1320
+ <span class='id identifier rubyid_include_empty'>include_empty</span> <span class='op'>=</span> <span class='op'>!</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:exclude_empty</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_to_boolean'>to_boolean</span>
1321
+ <span class='id identifier rubyid_exclude'>exclude</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:exclude</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='kw'>nil</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span>
1322
+ <span class='id identifier rubyid_keys'>keys</span> <span class='op'>=</span> <span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='kw'>nil</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='symbol'>:ensure_string</span><span class='rparen'>)</span>
1323
+
1324
+ <span class='id identifier rubyid_map_to_json'>map_to_json</span><span class='lparen'>(</span><span class='id identifier rubyid_target'>target</span><span class='comma'>,</span> <span class='lparen'>(</span><span class='id identifier rubyid_keys'>keys</span> <span class='op'>-</span> <span class='id identifier rubyid_exclude'>exclude</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_include_empty'>include_empty</span><span class='rparen'>)</span>
1325
+ <span class='kw'>end</span></pre>
1326
+ </td>
1327
+ </tr>
1328
+ </table>
1329
+ </div>
1330
+
1331
+ <div class="method_details ">
1332
+ <h3 class="signature " id="create_engine-instance_method">
1333
+
1334
+ - (<tt>Object</tt>) <strong>create_engine</strong>(cls, type = :parsing)
1335
+
1336
+
1337
+
1338
+
1339
+
1340
+ </h3><div class="docstring">
1341
+ <div class="discussion">
1342
+ <p>Instantiates a new engine for rendering or parsing.</p>
1343
+
1344
+
1345
+ </div>
1346
+ </div>
1347
+ <div class="tags">
1348
+ <p class="tag_title">Parameters:</p>
1349
+ <ul class="param">
1350
+
1351
+ <li>
1352
+
1353
+ <span class='name'>cls</span>
1354
+
1355
+
1356
+ <span class='type'>(<tt>String|Symbol|Object</tt>)</span>
1357
+
1358
+
1359
+
1360
+ &mdash;
1361
+ <div class='inline'><p>If a <code>String</code> or a <code>Symbol</code>, then it will be the class of the engine.</p>
1362
+ </div>
1363
+
1364
+ </li>
1365
+
1366
+ <li>
1367
+
1368
+ <span class='name'>type</span>
1369
+
1370
+
1371
+ <span class='type'>(<tt>Symbol</tt>)</span>
1372
+
1373
+
1374
+ <em class="default">(defaults to: <tt>:parsing</tt>)</em>
1375
+
1376
+
1377
+ &mdash;
1378
+ <div class='inline'><p>The type or engine. Can be <code>:parsing</code> or <code>:rendering</code>.</p>
1379
+ </div>
1380
+
1381
+ </li>
1382
+
1383
+ </ul>
1384
+
1385
+ <p class="tag_title">Returns:</p>
1386
+ <ul class="return">
1387
+
1388
+ <li>
1389
+
1390
+
1391
+ <span class='type'>(<tt>Object</tt>)</span>
1392
+
1393
+
1394
+
1395
+ &mdash;
1396
+ <div class='inline'><p>A new engine.</p>
1397
+ </div>
1398
+
1399
+ </li>
1400
+
1401
+ </ul>
1402
+
1403
+ </div><table class="source_code">
1404
+ <tr>
1405
+ <td>
1406
+ <pre class="lines">
1407
+
1408
+
1409
+ 89
1410
+ 90
1411
+ 91
1412
+ 92
1413
+ 93
1414
+ 94</pre>
1415
+ </td>
1416
+ <td>
1417
+ <pre class="code"><span class="info file"># File 'lib/mbrao/parser_interface.rb', line 89</span>
1418
+
1419
+ <span class='kw'>def</span> <span class='id identifier rubyid_create_engine'>create_engine</span><span class='lparen'>(</span><span class='id identifier rubyid_cls'>cls</span><span class='comma'>,</span> <span class='id identifier rubyid_type'>type</span> <span class='op'>=</span> <span class='symbol'>:parsing</span><span class='rparen'>)</span>
1420
+ <span class='id identifier rubyid_type'>type</span> <span class='op'>=</span> <span class='symbol'>:parsing</span> <span class='kw'>if</span> <span class='id identifier rubyid_type'>type</span> <span class='op'>!=</span> <span class='symbol'>:rendering</span>
1421
+ <span class='op'>::</span><span class='const'>Lazier</span><span class='period'>.</span><span class='id identifier rubyid_find_class'>find_class</span><span class='lparen'>(</span><span class='id identifier rubyid_cls'>cls</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>::Mbrao::</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_type'>type</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_classify'>classify</span><span class='embexpr_end'>}</span><span class='tstring_content'>Engines::%CLASS%</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
1422
+ <span class='kw'>rescue</span> <span class='const'>NameError</span>
1423
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Exceptions</span><span class='op'>::</span><span class='const'>UnknownEngine</span>
1424
+ <span class='kw'>end</span></pre>
1425
+ </td>
1426
+ </tr>
1427
+ </table>
1428
+ </div>
1429
+
1430
+ <div class="method_details ">
1431
+ <h3 class="signature " id="instance-instance_method">
1432
+
1433
+ - (<tt><span class='object_link'><a href="../Parser.html" title="Mbrao::Parser (class)">Parser</a></span></tt>) <strong>instance</strong>(force = false)
1434
+
1435
+
1436
+
1437
+
1438
+
1439
+ </h3><div class="docstring">
1440
+ <div class="discussion">
1441
+ <p>Returns a unique (singleton) instance of the parser.</p>
1442
+
1443
+
1444
+ </div>
1445
+ </div>
1446
+ <div class="tags">
1447
+ <p class="tag_title">Parameters:</p>
1448
+ <ul class="param">
1449
+
1450
+ <li>
1451
+
1452
+ <span class='name'>force</span>
1453
+
1454
+
1455
+ <span class='type'>(<tt>Boolean</tt>)</span>
1456
+
1457
+
1458
+ <em class="default">(defaults to: <tt>false</tt>)</em>
1459
+
1460
+
1461
+ &mdash;
1462
+ <div class='inline'><p>If to force recreation of the instance.</p>
1463
+ </div>
1464
+
1465
+ </li>
1466
+
1467
+ </ul>
1468
+
1469
+ <p class="tag_title">Returns:</p>
1470
+ <ul class="return">
1471
+
1472
+ <li>
1473
+
1474
+
1475
+ <span class='type'>(<tt><span class='object_link'><a href="../Parser.html" title="Mbrao::Parser (class)">Parser</a></span></tt>)</span>
1476
+
1477
+
1478
+
1479
+ &mdash;
1480
+ <div class='inline'><p>The unique (singleton) instance of the parser.</p>
1481
+ </div>
1482
+
1483
+ </li>
1484
+
1485
+ </ul>
1486
+
1487
+ </div><table class="source_code">
1488
+ <tr>
1489
+ <td>
1490
+ <pre class="lines">
1491
+
1492
+
1493
+ 100
1494
+ 101
1495
+ 102
1496
+ 103</pre>
1497
+ </td>
1498
+ <td>
1499
+ <pre class="code"><span class="info file"># File 'lib/mbrao/parser_interface.rb', line 100</span>
1500
+
1501
+ <span class='kw'>def</span> <span class='id identifier rubyid_instance'>instance</span><span class='lparen'>(</span><span class='id identifier rubyid_force'>force</span> <span class='op'>=</span> <span class='kw'>false</span><span class='rparen'>)</span>
1502
+ <span class='ivar'>@instance</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_force'>force</span>
1503
+ <span class='ivar'>@instance</span> <span class='op'>||=</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Parser</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
1504
+ <span class='kw'>end</span></pre>
1505
+ </td>
1506
+ </tr>
1507
+ </table>
1508
+ </div>
1509
+
1510
+ <div class="method_details ">
1511
+ <h3 class="signature " id="parse-instance_method">
1512
+
1513
+ - (<tt><span class='object_link'><a href="../Content.html" title="Mbrao::Content (class)">Content</a></span></tt>) <strong>parse</strong>(content, options = {})
1514
+
1515
+
1516
+
1517
+
1518
+
1519
+ </h3><div class="docstring">
1520
+ <div class="discussion">
1521
+ <p>Parses a source text.</p>
1522
+
1523
+
1524
+ </div>
1525
+ </div>
1526
+ <div class="tags">
1527
+ <p class="tag_title">Parameters:</p>
1528
+ <ul class="param">
1529
+
1530
+ <li>
1531
+
1532
+ <span class='name'>content</span>
1533
+
1534
+
1535
+ <span class='type'>(<tt>Object</tt>)</span>
1536
+
1537
+
1538
+
1539
+ &mdash;
1540
+ <div class='inline'><p>The content to parse.</p>
1541
+ </div>
1542
+
1543
+ </li>
1544
+
1545
+ <li>
1546
+
1547
+ <span class='name'>options</span>
1548
+
1549
+
1550
+ <span class='type'>(<tt>Hash</tt>)</span>
1551
+
1552
+
1553
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
1554
+
1555
+
1556
+ &mdash;
1557
+ <div class='inline'><p>A list of options for parsing.</p>
1558
+ </div>
1559
+
1560
+ </li>
1561
+
1562
+ </ul>
1563
+
1564
+ <p class="tag_title">Returns:</p>
1565
+ <ul class="return">
1566
+
1567
+ <li>
1568
+
1569
+
1570
+ <span class='type'>(<tt><span class='object_link'><a href="../Content.html" title="Mbrao::Content (class)">Content</a></span></tt>)</span>
1571
+
1572
+
1573
+
1574
+ &mdash;
1575
+ <div class='inline'><p>The parsed data.</p>
1576
+ </div>
1577
+
1578
+ </li>
1579
+
1580
+ </ul>
1581
+
1582
+ </div><table class="source_code">
1583
+ <tr>
1584
+ <td>
1585
+ <pre class="lines">
1586
+
1587
+
1588
+ 52
1589
+ 53
1590
+ 54</pre>
1591
+ </td>
1592
+ <td>
1593
+ <pre class="code"><span class="info file"># File 'lib/mbrao/parser_interface.rb', line 52</span>
1594
+
1595
+ <span class='kw'>def</span> <span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
1596
+ <span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
1597
+ <span class='kw'>end</span></pre>
1598
+ </td>
1599
+ </tr>
1600
+ </table>
1601
+ </div>
1602
+
1603
+ <div class="method_details ">
1604
+ <h3 class="signature " id="render-instance_method">
1605
+
1606
+ - (<tt>String</tt>) <strong>render</strong>(content, options = {}, context = {})
1607
+
1608
+
1609
+
1610
+
1611
+
1612
+ </h3><div class="docstring">
1613
+ <div class="discussion">
1614
+ <p>Renders a content.</p>
1615
+
1616
+
1617
+ </div>
1618
+ </div>
1619
+ <div class="tags">
1620
+ <p class="tag_title">Parameters:</p>
1621
+ <ul class="param">
1622
+
1623
+ <li>
1624
+
1625
+ <span class='name'>content</span>
1626
+
1627
+
1628
+ <span class='type'>(<tt><span class='object_link'><a href="../Content.html" title="Mbrao::Content (class)">Content</a></span></tt>)</span>
1629
+
1630
+
1631
+
1632
+ &mdash;
1633
+ <div class='inline'><p>The content to parse.</p>
1634
+ </div>
1635
+
1636
+ </li>
1637
+
1638
+ <li>
1639
+
1640
+ <span class='name'>options</span>
1641
+
1642
+
1643
+ <span class='type'>(<tt>Hash</tt>)</span>
1644
+
1645
+
1646
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
1647
+
1648
+
1649
+ &mdash;
1650
+ <div class='inline'><p>A list of options for renderer.</p>
1651
+ </div>
1652
+
1653
+ </li>
1654
+
1655
+ <li>
1656
+
1657
+ <span class='name'>context</span>
1658
+
1659
+
1660
+ <span class='type'>(<tt>Hash</tt>)</span>
1661
+
1662
+
1663
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
1664
+
1665
+
1666
+ &mdash;
1667
+ <div class='inline'><p>A context for rendering.</p>
1668
+ </div>
1669
+
1670
+ </li>
1671
+
1672
+ </ul>
1673
+
1674
+ <p class="tag_title">Returns:</p>
1675
+ <ul class="return">
1676
+
1677
+ <li>
1678
+
1679
+
1680
+ <span class='type'>(<tt>String</tt>)</span>
1681
+
1682
+
1683
+
1684
+ &mdash;
1685
+ <div class='inline'><p>The rendered content.</p>
1686
+ </div>
1687
+
1688
+ </li>
1689
+
1690
+ </ul>
1691
+
1692
+ </div><table class="source_code">
1693
+ <tr>
1694
+ <td>
1695
+ <pre class="lines">
1696
+
1697
+
1698
+ 62
1699
+ 63
1700
+ 64</pre>
1701
+ </td>
1702
+ <td>
1703
+ <pre class="code"><span class="info file"># File 'lib/mbrao/parser_interface.rb', line 62</span>
1704
+
1705
+ <span class='kw'>def</span> <span class='id identifier rubyid_render'>render</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='id identifier rubyid_context'>context</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
1706
+ <span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_render'>render</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='id identifier rubyid_context'>context</span><span class='rparen'>)</span>
1707
+ <span class='kw'>end</span></pre>
1708
+ </td>
1709
+ </tr>
1710
+ </table>
1711
+ </div>
1712
+
1713
+ </div>
1714
+
1715
+ </div>
1716
+
1717
+ <div id="footer">
1718
+ Generated on Sun May 11 18:17:17 2014 by
1719
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1720
+ 0.8.7.4 (ruby-2.1.0).
1721
+ </div>
1722
+
1723
+ </body>
1724
+ </html>