doc/classes/FileCache.src/M000378.html in ripxplore-0.11.0 vs doc/classes/FileCache.src/M000378.html in ripxplore-0.12.0

- old
+ new

@@ -3,21 +3,25 @@ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> - <title>make_file_system_image_list (FileCache)</title> + <title>random_file_system_image (FileCache)</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" /> </head> <body class="standalone-code"> - <pre><span class="ruby-comment cmt"># File lib/FileCache.rb, line 92</span> - <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">make_file_system_image_list</span> - <span class="ruby-identifier">urls</span>=[] - <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">glob</span>(<span class="ruby-node">&quot;#{url_cache_dir}/*.cached.info&quot;</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">info_file</span><span class="ruby-operator">|</span> - <span class="ruby-identifier">url</span>=<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">info_file</span>,<span class="ruby-value str">&quot;r&quot;</span>).<span class="ruby-identifier">read</span>.<span class="ruby-identifier">chomp</span> - <span class="ruby-identifier">urls</span><span class="ruby-operator">&lt;&lt;</span><span class="ruby-identifier">url</span> <span class="ruby-keyword kw">if</span> (<span class="ruby-constant">FileSystemImage</span>.<span class="ruby-identifier">is_file_system_image_filename?</span>(<span class="ruby-identifier">url</span>)) + <pre><span class="ruby-comment cmt"># File lib/FileCache.rb, line 102</span> + <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">random_file_system_image</span>(<span class="ruby-identifier">collection_type</span>=<span class="ruby-keyword kw">nil</span>) + <span class="ruby-identifier">all_image_urls</span>=<span class="ruby-identifier">file_system_image_urls_in_cache</span> + <span class="ruby-identifier">all_image_urls</span>.<span class="ruby-identifier">length</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword kw">do</span> + <span class="ruby-keyword kw">begin</span> + <span class="ruby-identifier">index</span>=<span class="ruby-identifier">rand</span>(<span class="ruby-identifier">all_image_urls</span>.<span class="ruby-identifier">length</span>) + <span class="ruby-identifier">image</span>=<span class="ruby-identifier">get_file_system_image</span>(<span class="ruby-identifier">all_image_urls</span>[<span class="ruby-identifier">index</span><span class="ruby-operator">%</span><span class="ruby-identifier">all_image_urls</span>.<span class="ruby-identifier">length</span>]) + <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">image</span> <span class="ruby-keyword kw">if</span> ((<span class="ruby-identifier">collection_type</span><span class="ruby-operator">==</span><span class="ruby-keyword kw">nil</span>) <span class="ruby-operator">||</span> (<span class="ruby-identifier">image</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">collection_type</span>).<span class="ruby-identifier">length</span><span class="ruby-operator">&gt;</span><span class="ruby-value">0</span>)) + <span class="ruby-keyword kw">rescue</span> <span class="ruby-comment cmt">#silently swallow any exception </span> + <span class="ruby-keyword kw">end</span> <span class="ruby-keyword kw">end</span> - <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-ivar">@url_cache_list</span>,<span class="ruby-value str">&quot;w&quot;</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-identifier">f</span><span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">urls</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;\n&quot;</span>)} + <span class="ruby-identifier">raise</span> <span class="ruby-value str">'no suitable image found in cache'</span> <span class="ruby-keyword kw">end</span></pre> </body> </html> \ No newline at end of file