sword2ruby 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. data/.gitignore +4 -0
  2. data/Gemfile +4 -0
  3. data/Gemfile.lock +30 -0
  4. data/LICENCE +35 -0
  5. data/README.md +43 -0
  6. data/Rakefile +53 -0
  7. data/doc/Atom/Collection.html +837 -0
  8. data/doc/Atom/Element.html +197 -0
  9. data/doc/Atom/Entry.html +1795 -0
  10. data/doc/Atom/Feed.html +297 -0
  11. data/doc/Atom/Service.html +363 -0
  12. data/doc/Atom.html +158 -0
  13. data/doc/Gemfile.html +125 -0
  14. data/doc/Object.html +165 -0
  15. data/doc/REXML/Element.html +493 -0
  16. data/doc/REXML.html +158 -0
  17. data/doc/Rakefile.html +123 -0
  18. data/doc/Sword2Ruby/Atom.html +169 -0
  19. data/doc/Sword2Ruby/AutoDiscover.html +327 -0
  20. data/doc/Sword2Ruby/Connection.html +274 -0
  21. data/doc/Sword2Ruby/DepositReceipt.html +331 -0
  22. data/doc/Sword2Ruby/Exception.html +168 -0
  23. data/doc/Sword2Ruby/SwordAccept.html +169 -0
  24. data/doc/Sword2Ruby/SwordStatementOAIORE.html +277 -0
  25. data/doc/Sword2Ruby/User.html +272 -0
  26. data/doc/Sword2Ruby/Utility.html +1101 -0
  27. data/doc/Sword2Ruby.html +213 -0
  28. data/doc/created.rid +29 -0
  29. data/doc/images/add.png +0 -0
  30. data/doc/images/brick.png +0 -0
  31. data/doc/images/brick_link.png +0 -0
  32. data/doc/images/bug.png +0 -0
  33. data/doc/images/bullet_black.png +0 -0
  34. data/doc/images/bullet_toggle_minus.png +0 -0
  35. data/doc/images/bullet_toggle_plus.png +0 -0
  36. data/doc/images/date.png +0 -0
  37. data/doc/images/delete.png +0 -0
  38. data/doc/images/find.png +0 -0
  39. data/doc/images/loadingAnimation.gif +0 -0
  40. data/doc/images/macFFBgHack.png +0 -0
  41. data/doc/images/package.png +0 -0
  42. data/doc/images/page_green.png +0 -0
  43. data/doc/images/page_white_text.png +0 -0
  44. data/doc/images/page_white_width.png +0 -0
  45. data/doc/images/plugin.png +0 -0
  46. data/doc/images/ruby.png +0 -0
  47. data/doc/images/tag_blue.png +0 -0
  48. data/doc/images/tag_green.png +0 -0
  49. data/doc/images/transparent.png +0 -0
  50. data/doc/images/wrench.png +0 -0
  51. data/doc/images/wrench_orange.png +0 -0
  52. data/doc/images/zoom.png +0 -0
  53. data/doc/index.html +118 -0
  54. data/doc/js/darkfish.js +153 -0
  55. data/doc/js/jquery.js +18 -0
  56. data/doc/js/navigation.js +142 -0
  57. data/doc/js/search.js +94 -0
  58. data/doc/js/search_index.js +1 -0
  59. data/doc/js/searcher.js +228 -0
  60. data/doc/rdoc.css +543 -0
  61. data/doc/spec/fixtures/example_txt.html +125 -0
  62. data/doc/table_of_contents.html +267 -0
  63. data/lib/sword2ruby/auto_discover.rb +71 -0
  64. data/lib/sword2ruby/collection.rb +261 -0
  65. data/lib/sword2ruby/connection.rb +37 -0
  66. data/lib/sword2ruby/constant.rb +35 -0
  67. data/lib/sword2ruby/deposit_receipt.rb +52 -0
  68. data/lib/sword2ruby/element.rb +12 -0
  69. data/lib/sword2ruby/entry.rb +602 -0
  70. data/lib/sword2ruby/exception.rb +7 -0
  71. data/lib/sword2ruby/feed.rb +34 -0
  72. data/lib/sword2ruby/rexml_element.rb +79 -0
  73. data/lib/sword2ruby/service.rb +79 -0
  74. data/lib/sword2ruby/sword_accept.rb +10 -0
  75. data/lib/sword2ruby/sword_statement_oai_ore.rb +38 -0
  76. data/lib/sword2ruby/user.rb +25 -0
  77. data/lib/sword2ruby/utility.rb +232 -0
  78. data/lib/sword2ruby/version.rb +4 -0
  79. data/lib/sword2ruby.rb +32 -0
  80. data/spec/auto_discover_spec.rb +30 -0
  81. data/spec/collection_spec.rb +33 -0
  82. data/spec/connection_spec.rb +21 -0
  83. data/spec/end_to_end_spec.rb +235 -0
  84. data/spec/fixtures/example.txt +3 -0
  85. data/spec/fixtures/snowflake.png +0 -0
  86. data/spec/fixtures/zip-test.zip +0 -0
  87. data/spec/service_spec.rb +38 -0
  88. data/spec/statement_spec.rb +53 -0
  89. data/spec/test_constants.rb +32 -0
  90. data/sword2ruby.gemspec +42 -0
  91. data/sword2ruby.tmproj +27 -0
  92. metadata +197 -0
@@ -0,0 +1,1101 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
6
+
7
+ <title>class Sword2Ruby::Utility - RDoc Documentation</title>
8
+
9
+ <link type="text/css" media="screen" href="../rdoc.css" rel="stylesheet">
10
+
11
+ <script type="text/javascript">
12
+ var rdoc_rel_prefix = "../";
13
+ </script>
14
+
15
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
16
+ <script type="text/javascript" charset="utf-8" src="../js/navigation.js"></script>
17
+ <script type="text/javascript" charset="utf-8" src="../js/search_index.js"></script>
18
+ <script type="text/javascript" charset="utf-8" src="../js/search.js"></script>
19
+ <script type="text/javascript" charset="utf-8" src="../js/searcher.js"></script>
20
+ <script type="text/javascript" charset="utf-8" src="../js/darkfish.js"></script>
21
+
22
+
23
+ <body id="top" class="class">
24
+ <nav id="metadata">
25
+ <nav id="home-section" class="section">
26
+ <h3 class="section-header">
27
+ <a href="../index.html">Home</a>
28
+ <a href="../table_of_contents.html#classes">Classes</a>
29
+ <a href="../table_of_contents.html#methods">Methods</a>
30
+ </h3>
31
+ </nav>
32
+
33
+
34
+ <nav id="search-section" class="section project-section" class="initially-hidden">
35
+ <form action="#" method="get" accept-charset="utf-8">
36
+ <h3 class="section-header">
37
+ <input type="text" name="search" placeholder="Search" id="search-field"
38
+ title="Type to search, Up and Down to navigate, Enter to load">
39
+ </h3>
40
+ </form>
41
+
42
+ <ul id="search-results" class="initially-hidden"></ul>
43
+ </nav>
44
+
45
+
46
+ <div id="file-metadata">
47
+ <nav id="file-list-section" class="section">
48
+ <h3 class="section-header">Defined In</h3>
49
+ <ul>
50
+ <li>lib/sword2ruby/utility.rb
51
+ </ul>
52
+ </nav>
53
+
54
+
55
+ </div>
56
+
57
+ <div id="class-metadata">
58
+
59
+ <nav id="parent-class-section" class="section">
60
+ <h3 class="section-header">Parent</h3>
61
+
62
+ <p class="link"><a href="../Object.html">Object</a>
63
+
64
+ </nav>
65
+
66
+
67
+ <!-- Method Quickref -->
68
+ <nav id="method-list-section" class="section">
69
+ <h3 class="section-header">Methods</h3>
70
+
71
+ <ul class="link-list">
72
+
73
+ <li><a href="#method-c-check_argument_class">::check_argument_class</a>
74
+
75
+ <li><a href="#method-c-check_uri">::check_uri</a>
76
+
77
+ <li><a href="#method-c-find_element_attribute_value">::find_element_attribute_value</a>
78
+
79
+ <li><a href="#method-c-find_element_boolean">::find_element_boolean</a>
80
+
81
+ <li><a href="#method-c-find_element_by_href">::find_element_by_href</a>
82
+
83
+ <li><a href="#method-c-find_element_by_name">::find_element_by_name</a>
84
+
85
+ <li><a href="#method-c-find_element_by_scheme_and_term">::find_element_by_scheme_and_term</a>
86
+
87
+ <li><a href="#method-c-find_element_integer">::find_element_integer</a>
88
+
89
+ <li><a href="#method-c-find_element_text">::find_element_text</a>
90
+
91
+ <li><a href="#method-c-find_element_time">::find_element_time</a>
92
+
93
+ <li><a href="#method-c-find_elements_attribute_value">::find_elements_attribute_value</a>
94
+
95
+ <li><a href="#method-c-find_elements_by_namespace">::find_elements_by_namespace</a>
96
+
97
+ <li><a href="#method-c-find_elements_by_scheme">::find_elements_by_scheme</a>
98
+
99
+ <li><a href="#method-c-find_elements_text">::find_elements_text</a>
100
+
101
+ <li><a href="#method-c-find_link_uri">::find_link_uri</a>
102
+
103
+ <li><a href="#method-c-find_links">::find_links</a>
104
+
105
+ <li><a href="#method-c-find_links_all_types">::find_links_all_types</a>
106
+
107
+ <li><a href="#method-c-read_file">::read_file</a>
108
+
109
+ <li><a href="#method-c-to_boolean">::to_boolean</a>
110
+
111
+ </ul>
112
+ </nav>
113
+
114
+ </div>
115
+
116
+ <div id="project-metadata">
117
+ <nav id="fileindex-section" class="section project-section">
118
+ <h3 class="section-header">Pages</h3>
119
+
120
+ <ul>
121
+
122
+ <li class="file"><a href="../Gemfile.html">Gemfile</a>
123
+
124
+ <li class="file"><a href="../Rakefile.html">Rakefile</a>
125
+
126
+ <li class="file"><a href="../spec/fixtures/example_txt.html">example</a>
127
+
128
+ </ul>
129
+ </nav>
130
+
131
+ <nav id="classindex-section" class="section project-section">
132
+ <h3 class="section-header">Class and Module Index</h3>
133
+
134
+ <ul class="link-list">
135
+
136
+ <li><a href="../Sword2Ruby.html">Sword2Ruby</a>
137
+
138
+ <li><a href="../Sword2Ruby/Atom.html">Sword2Ruby::Atom</a>
139
+
140
+ <li><a href="../Sword2Ruby/AutoDiscover.html">Sword2Ruby::AutoDiscover</a>
141
+
142
+ <li><a href="../Sword2Ruby/Connection.html">Sword2Ruby::Connection</a>
143
+
144
+ <li><a href="../Sword2Ruby/DepositReceipt.html">Sword2Ruby::DepositReceipt</a>
145
+
146
+ <li><a href="../Sword2Ruby/Exception.html">Sword2Ruby::Exception</a>
147
+
148
+ <li><a href="../Sword2Ruby/SwordAccept.html">Sword2Ruby::SwordAccept</a>
149
+
150
+ <li><a href="../Sword2Ruby/SwordStatementOAIORE.html">Sword2Ruby::SwordStatementOAIORE</a>
151
+
152
+ <li><a href="../Sword2Ruby/User.html">Sword2Ruby::User</a>
153
+
154
+ <li><a href="../Sword2Ruby/Utility.html">Sword2Ruby::Utility</a>
155
+
156
+ <li><a href="../Atom.html">Atom</a>
157
+
158
+ <li><a href="../Atom/Collection.html">Atom::Collection</a>
159
+
160
+ <li><a href="../Atom/Element.html">Atom::Element</a>
161
+
162
+ <li><a href="../Atom/Entry.html">Atom::Entry</a>
163
+
164
+ <li><a href="../Atom/Feed.html">Atom::Feed</a>
165
+
166
+ <li><a href="../Atom/Service.html">Atom::Service</a>
167
+
168
+ <li><a href="../REXML.html">REXML</a>
169
+
170
+ <li><a href="../REXML/Element.html">REXML::Element</a>
171
+
172
+ <li><a href="../Object.html">Object</a>
173
+
174
+ </ul>
175
+ </nav>
176
+
177
+ </div>
178
+ </nav>
179
+
180
+ <div id="documentation">
181
+ <h1 class="class">class Sword2Ruby::Utility</h1>
182
+
183
+ <div id="description" class="description">
184
+
185
+ </div><!-- description -->
186
+
187
+
188
+
189
+
190
+ <section id="5Buntitled-5D" class="documentation-section">
191
+
192
+
193
+
194
+
195
+
196
+
197
+
198
+
199
+ <!-- Methods -->
200
+
201
+ <section id="public-class-5Buntitled-5D-method-details" class="method-section section">
202
+ <h3 class="section-header">Public Class Methods</h3>
203
+
204
+
205
+ <div id="method-c-check_argument_class" class="method-detail ">
206
+
207
+ <div class="method-heading">
208
+ <span class="method-name">check_argument_class</span><span
209
+ class="method-args">(name, argument, expected_class)</span>
210
+ <span class="method-click-advice">click to toggle source</span>
211
+ </div>
212
+
213
+
214
+ <div class="method-description">
215
+
216
+ <p>Method to check the supplied argument is the expected class.</p>
217
+
218
+ <h3 id="method-c-check_argument_class-label-Parameters">Parameters</h3>
219
+ <dl class="rdoc-list note-list"><dt>name
220
+ <dd>
221
+ <p>the string name of the <strong>argument</strong> parameter, e.g.
222
+ “update_time” or “username”</p>
223
+ </dd><dt>argument
224
+ <dd>
225
+ <p>the object to be checked against <strong>expected_class</strong>, e.g.
226
+ update_time or username</p>
227
+ </dd><dt>expected_class
228
+ <dd>
229
+ <p>the class used to validate <strong>argument</strong>, e.g. Time or String</p>
230
+ </dd></dl>
231
+
232
+ <p>It will just return (nothing) if the check passes, or raise an
233
+ ArgumentError if the check fails.</p>
234
+
235
+ <h3 id="method-c-check_argument_class-label-Example">Example</h3>
236
+
237
+ <pre># This is fine
238
+ on_behalf_of = &quot;joebloggs&quot;
239
+ Utility.check_argument_class('on_behalf_of', on_behalf_of, String)
240
+
241
+ # This will raise an ArgumentError, because on_behalf_of is not a String
242
+ on_behalf_of = 12345
243
+ Utility.check_argument_class('on_behalf_of', on_behalf_of, String) #Raises an ArgumentError!</pre>
244
+
245
+
246
+
247
+ <div class="method-source-code" id="check_argument_class-source">
248
+ <pre><span class="ruby-comment"># File lib/sword2ruby/utility.rb, line 39</span>
249
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">check_argument_class</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">argument</span>, <span class="ruby-identifier">expected_class</span>)
250
+ <span class="ruby-keyword">unless</span> <span class="ruby-identifier">argument</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-identifier">expected_class</span>
251
+ <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">&quot;Argument '#{name}=#{argument}' must be of type '#{expected_class}' (and not of type '#{argument.class}')&quot;</span>)
252
+ <span class="ruby-keyword">end</span>
253
+ <span class="ruby-keyword">end</span></pre>
254
+ </div><!-- check_argument_class-source -->
255
+
256
+ </div>
257
+
258
+
259
+
260
+
261
+ </div><!-- check_argument_class-method -->
262
+
263
+
264
+ <div id="method-c-check_uri" class="method-detail ">
265
+
266
+ <div class="method-heading">
267
+ <span class="method-name">check_uri</span><span
268
+ class="method-args">(uri)</span>
269
+ <span class="method-click-advice">click to toggle source</span>
270
+ </div>
271
+
272
+
273
+ <div class="method-description">
274
+
275
+ <p>Method to check the supplied uri uses one of the URI schemes defined in
276
+ Sword2Ruby::VALID_URI_SCHEMES.</p>
277
+
278
+ <h3 id="method-c-check_uri-label-Parameters">Parameters</h3>
279
+ <dl class="rdoc-list note-list"><dt>uri
280
+ <dd>
281
+ <p>the string URI to be checked</p>
282
+ </dd></dl>
283
+
284
+ <p>It will just return (nothing) if the check passes, or raise an
285
+ InvalidURIError if the check fails. It will raise an ArgumentError if
286
+ <strong>uri</strong> is not a String. It wil raise a URI parse error if
287
+ <strong>uri</strong> could not be parsed.</p>
288
+
289
+ <h3 id="method-c-check_uri-label-Example">Example</h3>
290
+
291
+ <pre># This is fine
292
+ Utility.check_uri('http://www.url.com')
293
+
294
+ # This will raise an InvalidURIError, because fishy:// is not a valid URI scheme
295
+ Utility.check_uri('fishy://www.url.com')</pre>
296
+
297
+
298
+
299
+ <div class="method-source-code" id="check_uri-source">
300
+ <pre><span class="ruby-comment"># File lib/sword2ruby/utility.rb, line 56</span>
301
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">check_uri</span>(<span class="ruby-identifier">uri</span>)
302
+ <span class="ruby-keyword">self</span>.<span class="ruby-identifier">check_argument_class</span>(<span class="ruby-string">&quot;uri&quot;</span>, <span class="ruby-identifier">uri</span>, <span class="ruby-constant">String</span>)
303
+ <span class="ruby-keyword">unless</span> <span class="ruby-constant">VALID_URI_SCHEMES</span>.<span class="ruby-identifier">include?</span> <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">uri</span>).<span class="ruby-identifier">scheme</span>.<span class="ruby-identifier">downcase</span>.<span class="ruby-identifier">to_sym</span>
304
+ <span class="ruby-identifier">raise</span> <span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">InvalidURIError</span>, <span class="ruby-node">&quot;Invalid URI, it must start with either [#{VALID_URI_SCHEMES.join(',')}] (current value: #{uri})&quot;</span>
305
+ <span class="ruby-keyword">end</span>
306
+ <span class="ruby-keyword">end</span></pre>
307
+ </div><!-- check_uri-source -->
308
+
309
+ </div>
310
+
311
+
312
+
313
+
314
+ </div><!-- check_uri-method -->
315
+
316
+
317
+ <div id="method-c-find_element_attribute_value" class="method-detail ">
318
+
319
+ <div class="method-heading">
320
+ <span class="method-name">find_element_attribute_value</span><span
321
+ class="method-args">(elements, name, attribute_name)</span>
322
+ <span class="method-click-advice">click to toggle source</span>
323
+ </div>
324
+
325
+
326
+ <div class="method-description">
327
+
328
+ <p>Method to return the attribute value of first <a
329
+ href="../Atom/Element.html">Atom::Element</a> found in an array of
330
+ Atom::Elements by its name.</p>
331
+
332
+ <h3 id="method-c-find_element_attribute_value-label-Parameters">Parameters</h3>
333
+ <dl class="rdoc-list note-list"><dt>elements
334
+ <dd>
335
+ <p>an array of Atom::Elements</p>
336
+ </dd><dt>name
337
+ <dd>
338
+ <p>the expanded name of the element to search for, e.g. “sword:state” or
339
+ “sword:verboseDescription”</p>
340
+ </dd><dt>attribute_name
341
+ <dd>
342
+ <p>the name of the attribute to return the value of, e.g. “href”</p>
343
+ </dd></dl>
344
+
345
+ <p>It will return the value of the specified attribute of the first element
346
+ found with a matching name, othewise nil.</p>
347
+
348
+
349
+
350
+ <div class="method-source-code" id="find_element_attribute_value-source">
351
+ <pre><span class="ruby-comment"># File lib/sword2ruby/utility.rb, line 149</span>
352
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">find_element_attribute_value</span>(<span class="ruby-identifier">elements</span>, <span class="ruby-identifier">name</span>, <span class="ruby-identifier">attribute_name</span>)
353
+ <span class="ruby-identifier">elements</span>.<span class="ruby-identifier">find</span>(<span class="ruby-constant">NIL_LAMBDA</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">fully_expanded_name</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">name</span>}.<span class="ruby-identifier">attribute</span>(<span class="ruby-identifier">attribute_name</span>).<span class="ruby-identifier">value</span>
354
+ <span class="ruby-keyword">end</span></pre>
355
+ </div><!-- find_element_attribute_value-source -->
356
+
357
+ </div>
358
+
359
+
360
+
361
+
362
+ </div><!-- find_element_attribute_value-method -->
363
+
364
+
365
+ <div id="method-c-find_element_boolean" class="method-detail ">
366
+
367
+ <div class="method-heading">
368
+ <span class="method-name">find_element_boolean</span><span
369
+ class="method-args">(elements, name)</span>
370
+ <span class="method-click-advice">click to toggle source</span>
371
+ </div>
372
+
373
+
374
+ <div class="method-description">
375
+
376
+ <p>Method to return the boolean value of first <a
377
+ href="../Atom/Element.html">Atom::Element</a> found in an array of
378
+ Atom::Elements by its name.</p>
379
+
380
+ <h3 id="method-c-find_element_boolean-label-Parameters">Parameters</h3>
381
+ <dl class="rdoc-list note-list"><dt>elements
382
+ <dd>
383
+ <p>an array of Atom::Elements</p>
384
+ </dd><dt>name
385
+ <dd>
386
+ <p>the expanded name of the element to search for, e.g. “sword:state” or
387
+ “sword:verboseDescription”</p>
388
+ </dd></dl>
389
+
390
+ <p>It will return the boolean value of first element found with a matching
391
+ name, othewise nil.</p>
392
+
393
+
394
+
395
+ <div class="method-source-code" id="find_element_boolean-source">
396
+ <pre><span class="ruby-comment"># File lib/sword2ruby/utility.rb, line 129</span>
397
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">find_element_boolean</span>(<span class="ruby-identifier">elements</span>, <span class="ruby-identifier">name</span>)
398
+ <span class="ruby-keyword">self</span>.<span class="ruby-identifier">to_boolean</span>(<span class="ruby-identifier">find_element_text</span>(<span class="ruby-identifier">elements</span>, <span class="ruby-identifier">name</span>), <span class="ruby-keyword">nil</span>)
399
+ <span class="ruby-keyword">end</span></pre>
400
+ </div><!-- find_element_boolean-source -->
401
+
402
+ </div>
403
+
404
+
405
+
406
+
407
+ </div><!-- find_element_boolean-method -->
408
+
409
+
410
+ <div id="method-c-find_element_by_href" class="method-detail ">
411
+
412
+ <div class="method-heading">
413
+ <span class="method-name">find_element_by_href</span><span
414
+ class="method-args">(elements, href)</span>
415
+ <span class="method-click-advice">click to toggle source</span>
416
+ </div>
417
+
418
+
419
+ <div class="method-description">
420
+
421
+ <p>Method to return the first <a href="../Atom/Element.html">Atom::Element</a>
422
+ found in an array of Atom::Elements with a matching @href attribute.</p>
423
+
424
+ <h3 id="method-c-find_element_by_href-label-Parameters">Parameters</h3>
425
+ <dl class="rdoc-list note-list"><dt>elements
426
+ <dd>
427
+ <p>an array of Atom::Elements</p>
428
+ </dd><dt>href
429
+ <dd>
430
+ <p>the value of the @href attribute of the element to search for, e.g. “<a
431
+ href="http://purl.org/net/sword/terms/originalDeposit">purl.org/net/sword/terms/originalDeposit</a>”</p>
432
+ </dd></dl>
433
+
434
+ <p>It will return the first element found with a matching href attribute,
435
+ othewise nil.</p>
436
+
437
+
438
+
439
+ <div class="method-source-code" id="find_element_by_href-source">
440
+ <pre><span class="ruby-comment"># File lib/sword2ruby/utility.rb, line 168</span>
441
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">find_element_by_href</span>(<span class="ruby-identifier">elements</span>, <span class="ruby-identifier">href</span>)
442
+ <span class="ruby-identifier">elements</span>.<span class="ruby-identifier">find</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">href</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">href</span>}
443
+ <span class="ruby-keyword">end</span></pre>
444
+ </div><!-- find_element_by_href-source -->
445
+
446
+ </div>
447
+
448
+
449
+
450
+
451
+ </div><!-- find_element_by_href-method -->
452
+
453
+
454
+ <div id="method-c-find_element_by_name" class="method-detail ">
455
+
456
+ <div class="method-heading">
457
+ <span class="method-name">find_element_by_name</span><span
458
+ class="method-args">(elements, name)</span>
459
+ <span class="method-click-advice">click to toggle source</span>
460
+ </div>
461
+
462
+
463
+ <div class="method-description">
464
+
465
+ <p>Method to return the first <a href="../Atom/Element.html">Atom::Element</a>
466
+ found in an array of Atom::Elements by its name.</p>
467
+
468
+ <h3 id="method-c-find_element_by_name-label-Parameters">Parameters</h3>
469
+ <dl class="rdoc-list note-list"><dt>elements
470
+ <dd>
471
+ <p>an array of Atom::Elements</p>
472
+ </dd><dt>name
473
+ <dd>
474
+ <p>the expanded name of the element to search for, e.g. “sword:state” or
475
+ “sword:verboseDescription”</p>
476
+ </dd></dl>
477
+
478
+ <p>It will return the first element found with a matching name, othewise nil.</p>
479
+
480
+
481
+
482
+ <div class="method-source-code" id="find_element_by_name-source">
483
+ <pre><span class="ruby-comment"># File lib/sword2ruby/utility.rb, line 102</span>
484
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">find_element_by_name</span>(<span class="ruby-identifier">elements</span>, <span class="ruby-identifier">name</span>)
485
+ <span class="ruby-identifier">elements</span>.<span class="ruby-identifier">find</span>(<span class="ruby-constant">NIL_LAMBDA</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">fully_expanded_name</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">name</span>}
486
+ <span class="ruby-keyword">end</span></pre>
487
+ </div><!-- find_element_by_name-source -->
488
+
489
+ </div>
490
+
491
+
492
+
493
+
494
+ </div><!-- find_element_by_name-method -->
495
+
496
+
497
+ <div id="method-c-find_element_by_scheme_and_term" class="method-detail ">
498
+
499
+ <div class="method-heading">
500
+ <span class="method-name">find_element_by_scheme_and_term</span><span
501
+ class="method-args">(elements, scheme, term)</span>
502
+ <span class="method-click-advice">click to toggle source</span>
503
+ </div>
504
+
505
+
506
+ <div class="method-description">
507
+
508
+ <p>Method to return the first <a href="../Atom/Element.html">Atom::Element</a>
509
+ found in an array of Atom::Elements by its scheme and term.</p>
510
+
511
+ <h3 id="method-c-find_element_by_scheme_and_term-label-Parameters">Parameters</h3>
512
+ <dl class="rdoc-list note-list"><dt>elements
513
+ <dd>
514
+ <p>an array of Atom::Elements</p>
515
+ </dd><dt>scheme
516
+ <dd>
517
+ <p>the scheme of the element to search for, e.g. “<a
518
+ href="http://purl.org/net/sword/terms/">purl.org/net/sword/terms/</a>”</p>
519
+ </dd><dt>term
520
+ <dd>
521
+ <p>the term of the element to search for, e.g. “<a
522
+ href="http://purl.org/net/sword/terms/originalDeposit">purl.org/net/sword/terms/originalDeposit</a>”</p>
523
+ </dd></dl>
524
+
525
+ <p>It will return the first element found with a matching scheme and term,
526
+ othewise nil.</p>
527
+
528
+
529
+
530
+ <div class="method-source-code" id="find_element_by_scheme_and_term-source">
531
+ <pre><span class="ruby-comment"># File lib/sword2ruby/utility.rb, line 159</span>
532
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">find_element_by_scheme_and_term</span>(<span class="ruby-identifier">elements</span>, <span class="ruby-identifier">scheme</span>, <span class="ruby-identifier">term</span>)
533
+ <span class="ruby-identifier">elements</span>.<span class="ruby-identifier">find</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">scheme</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">term</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">term</span>}
534
+ <span class="ruby-keyword">end</span></pre>
535
+ </div><!-- find_element_by_scheme_and_term-source -->
536
+
537
+ </div>
538
+
539
+
540
+
541
+
542
+ </div><!-- find_element_by_scheme_and_term-method -->
543
+
544
+
545
+ <div id="method-c-find_element_integer" class="method-detail ">
546
+
547
+ <div class="method-heading">
548
+ <span class="method-name">find_element_integer</span><span
549
+ class="method-args">(elements, name)</span>
550
+ <span class="method-click-advice">click to toggle source</span>
551
+ </div>
552
+
553
+
554
+ <div class="method-description">
555
+
556
+ <p>Method to return the integer value of first <a
557
+ href="../Atom/Element.html">Atom::Element</a> found in an array of
558
+ Atom::Elements by its name.</p>
559
+
560
+ <h3 id="method-c-find_element_integer-label-Parameters">Parameters</h3>
561
+ <dl class="rdoc-list note-list"><dt>elements
562
+ <dd>
563
+ <p>an array of Atom::Elements</p>
564
+ </dd><dt>name
565
+ <dd>
566
+ <p>the expanded name of the element to search for, e.g. “sword:state” or
567
+ “sword:verboseDescription”</p>
568
+ </dd></dl>
569
+
570
+ <p>It will return the integer value of first element found with a matching
571
+ name, othewise 0.</p>
572
+
573
+
574
+
575
+ <div class="method-source-code" id="find_element_integer-source">
576
+ <pre><span class="ruby-comment"># File lib/sword2ruby/utility.rb, line 120</span>
577
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">find_element_integer</span>(<span class="ruby-identifier">elements</span>, <span class="ruby-identifier">name</span>)
578
+ <span class="ruby-identifier">find_element_text</span>(<span class="ruby-identifier">elements</span>, <span class="ruby-identifier">name</span>).<span class="ruby-identifier">to_i</span>
579
+ <span class="ruby-keyword">end</span></pre>
580
+ </div><!-- find_element_integer-source -->
581
+
582
+ </div>
583
+
584
+
585
+
586
+
587
+ </div><!-- find_element_integer-method -->
588
+
589
+
590
+ <div id="method-c-find_element_text" class="method-detail ">
591
+
592
+ <div class="method-heading">
593
+ <span class="method-name">find_element_text</span><span
594
+ class="method-args">(elements, name)</span>
595
+ <span class="method-click-advice">click to toggle source</span>
596
+ </div>
597
+
598
+
599
+ <div class="method-description">
600
+
601
+ <p>Method to return the text value of first <a
602
+ href="../Atom/Element.html">Atom::Element</a> found in an array of
603
+ Atom::Elements by its name.</p>
604
+
605
+ <h3 id="method-c-find_element_text-label-Parameters">Parameters</h3>
606
+ <dl class="rdoc-list note-list"><dt>elements
607
+ <dd>
608
+ <p>an array of Atom::Elements</p>
609
+ </dd><dt>name
610
+ <dd>
611
+ <p>the expanded name of the element to search for, e.g. “sword:state” or
612
+ “sword:verboseDescription”</p>
613
+ </dd></dl>
614
+
615
+ <p>It will return the text value of first element found with a matching name,
616
+ othewise nil.</p>
617
+
618
+
619
+
620
+ <div class="method-source-code" id="find_element_text-source">
621
+ <pre><span class="ruby-comment"># File lib/sword2ruby/utility.rb, line 111</span>
622
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">find_element_text</span>(<span class="ruby-identifier">elements</span>, <span class="ruby-identifier">name</span>)
623
+ <span class="ruby-identifier">find_element_by_name</span>(<span class="ruby-identifier">elements</span>, <span class="ruby-identifier">name</span>).<span class="ruby-identifier">text</span>
624
+ <span class="ruby-keyword">end</span></pre>
625
+ </div><!-- find_element_text-source -->
626
+
627
+ </div>
628
+
629
+
630
+
631
+
632
+ </div><!-- find_element_text-method -->
633
+
634
+
635
+ <div id="method-c-find_element_time" class="method-detail ">
636
+
637
+ <div class="method-heading">
638
+ <span class="method-name">find_element_time</span><span
639
+ class="method-args">(elements, name)</span>
640
+ <span class="method-click-advice">click to toggle source</span>
641
+ </div>
642
+
643
+
644
+ <div class="method-description">
645
+
646
+ <p>Method to return the time value of first <a
647
+ href="../Atom/Element.html">Atom::Element</a> found in an array of
648
+ Atom::Elements by its name.</p>
649
+
650
+ <h3 id="method-c-find_element_time-label-Parameters">Parameters</h3>
651
+ <dl class="rdoc-list note-list"><dt>elements
652
+ <dd>
653
+ <p>an array of Atom::Elements</p>
654
+ </dd><dt>name
655
+ <dd>
656
+ <p>the expanded name of the element to search for, e.g. “sword:state” or
657
+ “sword:verboseDescription”</p>
658
+ </dd></dl>
659
+
660
+ <p>It will return the time value of first element found with a matching name,
661
+ othewise nil.</p>
662
+
663
+
664
+
665
+ <div class="method-source-code" id="find_element_time-source">
666
+ <pre><span class="ruby-comment"># File lib/sword2ruby/utility.rb, line 138</span>
667
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">find_element_time</span>(<span class="ruby-identifier">elements</span>, <span class="ruby-identifier">name</span>)
668
+ <span class="ruby-identifier">value</span> = <span class="ruby-identifier">find_element_text</span>(<span class="ruby-identifier">elements</span>, <span class="ruby-identifier">name</span>)
669
+ <span class="ruby-identifier">value</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">?</span> <span class="ruby-keyword">nil</span> <span class="ruby-operator">:</span> <span class="ruby-constant">Time</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">find_element_text</span>(<span class="ruby-identifier">elements</span>, <span class="ruby-identifier">name</span>))
670
+ <span class="ruby-keyword">end</span></pre>
671
+ </div><!-- find_element_time-source -->
672
+
673
+ </div>
674
+
675
+
676
+
677
+
678
+ </div><!-- find_element_time-method -->
679
+
680
+
681
+ <div id="method-c-find_elements_attribute_value" class="method-detail ">
682
+
683
+ <div class="method-heading">
684
+ <span class="method-name">find_elements_attribute_value</span><span
685
+ class="method-args">(elements, name, attribute_name)</span>
686
+ <span class="method-click-advice">click to toggle source</span>
687
+ </div>
688
+
689
+
690
+ <div class="method-description">
691
+
692
+ <p>Method to return an array of attribute values of matching Atom::Elements
693
+ found in an array of Atom::Elements by their name.</p>
694
+
695
+ <h3 id="method-c-find_elements_attribute_value-label-Parameters">Parameters</h3>
696
+ <dl class="rdoc-list note-list"><dt>elements
697
+ <dd>
698
+ <p>an array of Atom::Elements</p>
699
+ </dd><dt>name
700
+ <dd>
701
+ <p>the expanded name of the element(s) to search for, e.g. “sword:state” or
702
+ “sword:verboseDescription”</p>
703
+ </dd><dt>attribute_name
704
+ <dd>
705
+ <p>the name of the attributes to return the value of, e.g. “href”</p>
706
+ </dd></dl>
707
+
708
+ <p>It will return an array of the attribute values of elements found with a
709
+ matching name, othewise an empty array [ ].</p>
710
+
711
+
712
+
713
+ <div class="method-source-code" id="find_elements_attribute_value-source">
714
+ <pre><span class="ruby-comment"># File lib/sword2ruby/utility.rb, line 190</span>
715
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">find_elements_attribute_value</span>(<span class="ruby-identifier">elements</span>, <span class="ruby-identifier">name</span>, <span class="ruby-identifier">attribute_name</span>)
716
+ <span class="ruby-identifier">elements</span>.<span class="ruby-identifier">find_all</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">fully_expanded_name</span><span class="ruby-operator">==</span><span class="ruby-identifier">name</span>}.<span class="ruby-identifier">collect</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">attribute</span>(<span class="ruby-identifier">attribute_name</span>).<span class="ruby-identifier">value</span>}
717
+ <span class="ruby-keyword">end</span></pre>
718
+ </div><!-- find_elements_attribute_value-source -->
719
+
720
+ </div>
721
+
722
+
723
+
724
+
725
+ </div><!-- find_elements_attribute_value-method -->
726
+
727
+
728
+ <div id="method-c-find_elements_by_namespace" class="method-detail ">
729
+
730
+ <div class="method-heading">
731
+ <span class="method-name">find_elements_by_namespace</span><span
732
+ class="method-args">(elements, namespace)</span>
733
+ <span class="method-click-advice">click to toggle source</span>
734
+ </div>
735
+
736
+
737
+ <div class="method-description">
738
+
739
+ <p>Method to return an array of matching Atom::Elements found in an array of
740
+ Atom::Elements by their namespace.</p>
741
+
742
+ <h3 id="method-c-find_elements_by_namespace-label-Parameters">Parameters</h3>
743
+ <dl class="rdoc-list note-list"><dt>elements
744
+ <dd>
745
+ <p>an array of Atom::Elements</p>
746
+ </dd><dt>namespace
747
+ <dd>
748
+ <p>the namespace to search for, e.g. “<a
749
+ href="http://purl.org/dc/terms/">purl.org/dc/terms/</a>”</p>
750
+ </dd></dl>
751
+
752
+ <p>It will return an array of Atom::Elements found with a matching namespace,
753
+ othewise an empty array [ ].</p>
754
+
755
+
756
+
757
+ <div class="method-source-code" id="find_elements_by_namespace-source">
758
+ <pre><span class="ruby-comment"># File lib/sword2ruby/utility.rb, line 199</span>
759
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">find_elements_by_namespace</span>(<span class="ruby-identifier">elements</span>, <span class="ruby-identifier">namespace</span>)
760
+ <span class="ruby-identifier">elements</span>.<span class="ruby-identifier">find_all</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">namespace</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">namespace</span>}
761
+ <span class="ruby-keyword">end</span></pre>
762
+ </div><!-- find_elements_by_namespace-source -->
763
+
764
+ </div>
765
+
766
+
767
+
768
+
769
+ </div><!-- find_elements_by_namespace-method -->
770
+
771
+
772
+ <div id="method-c-find_elements_by_scheme" class="method-detail ">
773
+
774
+ <div class="method-heading">
775
+ <span class="method-name">find_elements_by_scheme</span><span
776
+ class="method-args">(elements, scheme)</span>
777
+ <span class="method-click-advice">click to toggle source</span>
778
+ </div>
779
+
780
+
781
+ <div class="method-description">
782
+
783
+ <p>Method to return an array of matching Atom::Elements found in an array of
784
+ Atom::Elements by their namespace.</p>
785
+
786
+ <h3 id="method-c-find_elements_by_scheme-label-Parameters">Parameters</h3>
787
+ <dl class="rdoc-list note-list"><dt>elements
788
+ <dd>
789
+ <p>an array of Atom::Elements</p>
790
+ </dd><dt>scheme
791
+ <dd>
792
+ <p>the scheme to search for, e.g. “<a
793
+ href="http://purl.org/net/sword/terms/state">purl.org/net/sword/terms/state</a>”</p>
794
+ </dd></dl>
795
+
796
+ <p>It will return an array of Atom::Elements found with a matching scheme,
797
+ othewise an empty array [ ].</p>
798
+
799
+
800
+
801
+ <div class="method-source-code" id="find_elements_by_scheme-source">
802
+ <pre><span class="ruby-comment"># File lib/sword2ruby/utility.rb, line 209</span>
803
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">find_elements_by_scheme</span>(<span class="ruby-identifier">elements</span>, <span class="ruby-identifier">scheme</span>)
804
+ <span class="ruby-identifier">elements</span>.<span class="ruby-identifier">find_all</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">scheme</span>}
805
+ <span class="ruby-keyword">end</span></pre>
806
+ </div><!-- find_elements_by_scheme-source -->
807
+
808
+ </div>
809
+
810
+
811
+
812
+
813
+ </div><!-- find_elements_by_scheme-method -->
814
+
815
+
816
+ <div id="method-c-find_elements_text" class="method-detail ">
817
+
818
+ <div class="method-heading">
819
+ <span class="method-name">find_elements_text</span><span
820
+ class="method-args">(elements, name)</span>
821
+ <span class="method-click-advice">click to toggle source</span>
822
+ </div>
823
+
824
+
825
+ <div class="method-description">
826
+
827
+ <p>Method to return an array of text values of matching Atom::Elements found
828
+ in an array of Atom::Elements by their name.</p>
829
+
830
+ <h3 id="method-c-find_elements_text-label-Parameters">Parameters</h3>
831
+ <dl class="rdoc-list note-list"><dt>elements
832
+ <dd>
833
+ <p>an array of Atom::Elements</p>
834
+ </dd><dt>name
835
+ <dd>
836
+ <p>the expanded name of the element(s) to search for, e.g. “sword:state” or
837
+ “sword:verboseDescription”</p>
838
+ </dd></dl>
839
+
840
+ <p>It will return an array of the text values of elements found with a
841
+ matching name, othewise an empty array [ ].</p>
842
+
843
+
844
+
845
+ <div class="method-source-code" id="find_elements_text-source">
846
+ <pre><span class="ruby-comment"># File lib/sword2ruby/utility.rb, line 180</span>
847
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">find_elements_text</span>(<span class="ruby-identifier">elements</span>, <span class="ruby-identifier">name</span>)
848
+ <span class="ruby-identifier">elements</span>.<span class="ruby-identifier">find_all</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">fully_expanded_name</span><span class="ruby-operator">==</span><span class="ruby-identifier">name</span>}.<span class="ruby-identifier">collect</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">text</span>}
849
+ <span class="ruby-keyword">end</span></pre>
850
+ </div><!-- find_elements_text-source -->
851
+
852
+ </div>
853
+
854
+
855
+
856
+
857
+ </div><!-- find_elements_text-method -->
858
+
859
+
860
+ <div id="method-c-find_link_uri" class="method-detail ">
861
+
862
+ <div class="method-heading">
863
+ <span class="method-name">find_link_uri</span><span
864
+ class="method-args">(links, rel, type = nil)</span>
865
+ <span class="method-click-advice">click to toggle source</span>
866
+ </div>
867
+
868
+
869
+ <div class="method-description">
870
+
871
+ <p>Method to return the @href attribute of the Atom::Link found in an array of
872
+ Atom::Links by its @rel and @type attributes.</p>
873
+
874
+ <h3 id="method-c-find_link_uri-label-Parameters">Parameters</h3>
875
+ <dl class="rdoc-list note-list"><dt>links
876
+ <dd>
877
+ <p>an array of Atom::Links</p>
878
+ </dd><dt>rel
879
+ <dd>
880
+ <p>the string @rel value to search the array for</p>
881
+ </dd><dt>type
882
+ <dd>
883
+ <p>(optional) the string @type value to search the array for, defaults to nil</p>
884
+ </dd></dl>
885
+
886
+ <p>It will return the href value of the first link found with matching @rel
887
+ and @type values, othewise nil.</p>
888
+
889
+
890
+
891
+ <div class="method-source-code" id="find_link_uri-source">
892
+ <pre><span class="ruby-comment"># File lib/sword2ruby/utility.rb, line 71</span>
893
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">find_link_uri</span>(<span class="ruby-identifier">links</span>, <span class="ruby-identifier">rel</span>, <span class="ruby-identifier">type</span> = <span class="ruby-keyword">nil</span>)
894
+ <span class="ruby-identifier">links</span>.<span class="ruby-identifier">find</span>(<span class="ruby-constant">NIL_LAMBDA</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">link</span><span class="ruby-operator">|</span> <span class="ruby-identifier">link</span>.<span class="ruby-identifier">rel</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">rel</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">link</span>.<span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">type</span>}.<span class="ruby-identifier">href</span>
895
+ <span class="ruby-keyword">end</span></pre>
896
+ </div><!-- find_link_uri-source -->
897
+
898
+ </div>
899
+
900
+
901
+
902
+
903
+ </div><!-- find_link_uri-method -->
904
+
905
+
906
+ <div id="method-c-find_links" class="method-detail ">
907
+
908
+ <div class="method-heading">
909
+ <span class="method-name">find_links</span><span
910
+ class="method-args">(links, rel, type = nil)</span>
911
+ <span class="method-click-advice">click to toggle source</span>
912
+ </div>
913
+
914
+
915
+ <div class="method-description">
916
+
917
+ <p>Method to return an array of Atom::Links found in an array of Atom::Links
918
+ by their @rel and @type attributes.</p>
919
+
920
+ <h3 id="method-c-find_links-label-Parameters">Parameters</h3>
921
+ <dl class="rdoc-list note-list"><dt>links
922
+ <dd>
923
+ <p>an array of Atom::Links</p>
924
+ </dd><dt>rel
925
+ <dd>
926
+ <p>the string @rel value to search the array for</p>
927
+ </dd><dt>type
928
+ <dd>
929
+ <p>(optional) the string @type value to search the array for, defaults to nil</p>
930
+ </dd></dl>
931
+
932
+ <p>It will return an array of all matching Atom:Links (found with @rel and
933
+ @type values), othewise an empty array.</p>
934
+
935
+
936
+
937
+ <div class="method-source-code" id="find_links-source">
938
+ <pre><span class="ruby-comment"># File lib/sword2ruby/utility.rb, line 81</span>
939
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">find_links</span>(<span class="ruby-identifier">links</span>, <span class="ruby-identifier">rel</span>, <span class="ruby-identifier">type</span> = <span class="ruby-keyword">nil</span>)
940
+ <span class="ruby-identifier">links</span>.<span class="ruby-identifier">find_all</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">link</span><span class="ruby-operator">|</span> <span class="ruby-identifier">link</span>.<span class="ruby-identifier">rel</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">rel</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">link</span>.<span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">type</span>}
941
+ <span class="ruby-keyword">end</span></pre>
942
+ </div><!-- find_links-source -->
943
+
944
+ </div>
945
+
946
+
947
+
948
+
949
+ </div><!-- find_links-method -->
950
+
951
+
952
+ <div id="method-c-find_links_all_types" class="method-detail ">
953
+
954
+ <div class="method-heading">
955
+ <span class="method-name">find_links_all_types</span><span
956
+ class="method-args">(links, rel)</span>
957
+ <span class="method-click-advice">click to toggle source</span>
958
+ </div>
959
+
960
+
961
+ <div class="method-description">
962
+
963
+ <p>Method to return an array of Atom::Links found in an array of Atom::Links
964
+ by their @rel attributes.</p>
965
+
966
+ <h3 id="method-c-find_links_all_types-label-Parameters">Parameters</h3>
967
+ <dl class="rdoc-list note-list"><dt>links
968
+ <dd>
969
+ <p>an array of Atom::Links</p>
970
+ </dd><dt>rel
971
+ <dd>
972
+ <p>the string @rel value to search the array for</p>
973
+ </dd></dl>
974
+
975
+ <p>It will return an array of all matching Atom:Links (found with @rel),
976
+ othewise an empty array.</p>
977
+
978
+
979
+
980
+ <div class="method-source-code" id="find_links_all_types-source">
981
+ <pre><span class="ruby-comment"># File lib/sword2ruby/utility.rb, line 90</span>
982
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">find_links_all_types</span>(<span class="ruby-identifier">links</span>, <span class="ruby-identifier">rel</span>)
983
+ <span class="ruby-identifier">links</span>.<span class="ruby-identifier">find_all</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">link</span><span class="ruby-operator">|</span> <span class="ruby-identifier">link</span>.<span class="ruby-identifier">rel</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">rel</span>}
984
+ <span class="ruby-keyword">end</span></pre>
985
+ </div><!-- find_links_all_types-source -->
986
+
987
+ </div>
988
+
989
+
990
+
991
+
992
+ </div><!-- find_links_all_types-method -->
993
+
994
+
995
+ <div id="method-c-read_file" class="method-detail ">
996
+
997
+ <div class="method-heading">
998
+ <span class="method-name">read_file</span><span
999
+ class="method-args">(filepath)</span>
1000
+ <span class="method-click-advice">click to toggle source</span>
1001
+ </div>
1002
+
1003
+
1004
+ <div class="method-description">
1005
+
1006
+ <p>Method to return the filename, MD5 hash and filedata of the supplied
1007
+ filepath.</p>
1008
+
1009
+ <h3 id="method-c-read_file-label-Parameters">Parameters</h3>
1010
+ <dl class="rdoc-list note-list"><dt>filepath
1011
+ <dd>
1012
+ <p>path to an existing file which must be readable to the Ruby process.</p>
1013
+ </dd></dl>
1014
+
1015
+ <p>Returns an array of the form [filename, md5_digest, data]</p>
1016
+
1017
+
1018
+
1019
+ <div class="method-source-code" id="read_file-source">
1020
+ <pre><span class="ruby-comment"># File lib/sword2ruby/utility.rb, line 217</span>
1021
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">read_file</span>(<span class="ruby-identifier">filepath</span>)
1022
+ <span class="ruby-identifier">data</span> = <span class="ruby-keyword">nil</span>
1023
+ <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">filepath</span>,<span class="ruby-string">'r'</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span>
1024
+ <span class="ruby-identifier">data</span> = <span class="ruby-identifier">file</span>.<span class="ruby-identifier">gets</span>(<span class="ruby-keyword">nil</span>) <span class="ruby-comment">#Read entire file, no Base64.encode64()</span>
1025
+ <span class="ruby-keyword">end</span> <span class="ruby-comment">#file is closed automatically</span>
1026
+ <span class="ruby-keyword">return</span> [<span class="ruby-constant">File</span>.<span class="ruby-identifier">basename</span>(<span class="ruby-identifier">filepath</span>), <span class="ruby-constant">Digest</span><span class="ruby-operator">::</span><span class="ruby-constant">MD5</span>.<span class="ruby-identifier">hexdigest</span>(<span class="ruby-identifier">data</span>), <span class="ruby-identifier">data</span>]
1027
+ <span class="ruby-keyword">end</span></pre>
1028
+ </div><!-- read_file-source -->
1029
+
1030
+ </div>
1031
+
1032
+
1033
+
1034
+
1035
+ </div><!-- read_file-method -->
1036
+
1037
+
1038
+ <div id="method-c-to_boolean" class="method-detail ">
1039
+
1040
+ <div class="method-heading">
1041
+ <span class="method-name">to_boolean</span><span
1042
+ class="method-args">(value, nil_value = false)</span>
1043
+ <span class="method-click-advice">click to toggle source</span>
1044
+ </div>
1045
+
1046
+
1047
+ <div class="method-description">
1048
+
1049
+ <p>Method to cast a (typically) string value into a boolean value</p>
1050
+
1051
+ <h3 id="method-c-to_boolean-label-Parameters">Parameters</h3>
1052
+ <dl class="rdoc-list note-list"><dt>value
1053
+ <dd>
1054
+ <p>the string value to be cast, e.g. “true” or “no”</p>
1055
+ </dd><dt>nil_value
1056
+ <dd>
1057
+ <p>(optional) value to return if value=nil. If not supplied, this will default
1058
+ to false. Typically used in circumstances when returning something other
1059
+ than false would be preferable if value=nil.</p>
1060
+ </dd></dl>
1061
+
1062
+
1063
+
1064
+ <div class="method-source-code" id="to_boolean-source">
1065
+ <pre><span class="ruby-comment"># File lib/sword2ruby/utility.rb, line 11</span>
1066
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">to_boolean</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">nil_value</span> = <span class="ruby-keyword">false</span>)
1067
+ <span class="ruby-identifier">value</span>.<span class="ruby-identifier">downcase!</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">String</span>
1068
+ <span class="ruby-keyword">case</span> <span class="ruby-identifier">value</span>
1069
+ <span class="ruby-keyword">when</span> <span class="ruby-string">&quot;no&quot;</span>,<span class="ruby-string">&quot;false&quot;</span>,<span class="ruby-keyword">false</span>, <span class="ruby-string">&quot;0&quot;</span>, <span class="ruby-value">0</span>
1070
+ <span class="ruby-keyword">false</span>
1071
+ <span class="ruby-keyword">when</span> <span class="ruby-string">&quot;yes&quot;</span>,<span class="ruby-string">&quot;true&quot;</span>,<span class="ruby-keyword">true</span>, <span class="ruby-string">&quot;1&quot;</span>, <span class="ruby-value">1</span>
1072
+ <span class="ruby-keyword">true</span>
1073
+ <span class="ruby-keyword">when</span> <span class="ruby-keyword">nil</span>
1074
+ <span class="ruby-identifier">nil_value</span>
1075
+ <span class="ruby-keyword">else</span>
1076
+ <span class="ruby-operator">!</span><span class="ruby-operator">!</span><span class="ruby-identifier">value</span>
1077
+ <span class="ruby-keyword">end</span>
1078
+ <span class="ruby-keyword">end</span></pre>
1079
+ </div><!-- to_boolean-source -->
1080
+
1081
+ </div>
1082
+
1083
+
1084
+
1085
+
1086
+ </div><!-- to_boolean-method -->
1087
+
1088
+
1089
+ </section><!-- public-class-method-details -->
1090
+
1091
+ </section><!-- 5Buntitled-5D -->
1092
+
1093
+ </div><!-- documentation -->
1094
+
1095
+
1096
+ <footer id="validator-badges">
1097
+ <p><a href="http://validator.w3.org/check/referer">[Validate]</a>
1098
+ <p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.
1099
+ <p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
1100
+ </footer>
1101
+