doc/classes/FileSystemImage.src/M000294.html in ripxplore-0.11.0 vs doc/classes/FileSystemImage.src/M000294.html in ripxplore-0.12.0

- old
+ new

@@ -3,39 +3,25 @@ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> - <title>best_fit (FileSystemImage)</title> + <title>compatability_score (FileSystemImage)</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/FileSystemImage.rb, line 20</span> -<span class="ruby-keyword kw">def</span> <span class="ruby-constant">FileSystemImage</span>.<span class="ruby-identifier">best_fit</span>(<span class="ruby-identifier">file_bytes</span>,<span class="ruby-identifier">filename</span>=<span class="ruby-keyword kw">nil</span>) - <span class="ruby-identifier">candidates</span>=[] - <span class="ruby-identifier">file_ext</span>=<span class="ruby-constant">File</span>.<span class="ruby-identifier">extname</span>(<span class="ruby-identifier">filename</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-regexp re">/\.gz$/</span>,<span class="ruby-value str">&quot;&quot;</span>)).<span class="ruby-identifier">downcase</span> - <span class="ruby-constant">RipXploreLog</span>.<span class="ruby-identifier">debug</span>(<span class="ruby-node">&quot;looking for best fit for image format for #{filename} : extension #{file_ext}&quot;</span>) - <span class="ruby-constant">ImageFormat</span>.<span class="ruby-identifier">all_image_formats</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">image_format</span><span class="ruby-operator">|</span> - <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">file_ext</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">image_format</span>.<span class="ruby-identifier">possible_extensions</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">file_ext</span>) <span class="ruby-keyword kw">then</span> - <span class="ruby-constant">RipXploreLog</span>.<span class="ruby-identifier">debug</span>(<span class="ruby-node">&quot;skipping #{image_format} - unmatched extension #{file_ext}&quot;</span>) + <pre><span class="ruby-comment cmt"># File lib/FileSystemImage.rb, line 48</span> +<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">compatability_score</span> + <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@compatability_score</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-keyword kw">then</span> + <span class="ruby-identifier">image_format_compatability_score</span>=<span class="ruby-identifier">image_format</span>.<span class="ruby-identifier">compatability_score</span>(<span class="ruby-keyword kw">self</span>) + <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">image_format_compatability_score</span><span class="ruby-operator">&gt;</span><span class="ruby-value">0</span> <span class="ruby-keyword kw">then</span> <span class="ruby-comment cmt">#if we don't have a valid image_format, don't bother checking the file_system! </span> + <span class="ruby-identifier">file_system_compatability_score</span>=<span class="ruby-identifier">file_system</span>.<span class="ruby-identifier">compatability_score</span>(<span class="ruby-keyword kw">self</span>) + <span class="ruby-ivar">@compatability_score</span>=<span class="ruby-identifier">file_system_compatability_score</span><span class="ruby-operator">*</span><span class="ruby-identifier">image_format_compatability_score</span> <span class="ruby-keyword kw">else</span> - <span class="ruby-identifier">image_format</span>.<span class="ruby-identifier">possible_file_systems</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">file_system</span><span class="ruby-operator">|</span> - <span class="ruby-constant">RipXploreLog</span>.<span class="ruby-identifier">debug</span>(<span class="ruby-node">&quot;checking image format #{image_format} and file system #{file_system}&quot;</span>) - <span class="ruby-identifier">candidate</span>=<span class="ruby-constant">FileSystemImage</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">file_bytes</span>,<span class="ruby-identifier">file_system</span>,<span class="ruby-identifier">image_format</span>,<span class="ruby-identifier">filename</span>) - <span class="ruby-constant">RipXploreLog</span>.<span class="ruby-identifier">debug</span>(<span class="ruby-node">&quot;score - #{candidate.compatability_score}&quot;</span>) - <span class="ruby-identifier">candidates</span><span class="ruby-operator">&lt;&lt;</span><span class="ruby-identifier">candidate</span> - <span class="ruby-keyword kw">end</span> - <span class="ruby-keyword kw">end</span> + <span class="ruby-ivar">@compatability_score</span>=<span class="ruby-value">0</span> + <span class="ruby-keyword kw">end</span> <span class="ruby-keyword kw">end</span> - - - <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">candidates</span>.<span class="ruby-identifier">length</span><span class="ruby-operator">==</span><span class="ruby-value">0</span> <span class="ruby-keyword kw">then</span> - <span class="ruby-constant">RipXploreLog</span>.<span class="ruby-identifier">debug</span>( <span class="ruby-value str">'no valid combination of file system and image format found'</span>) - <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> - <span class="ruby-keyword kw">end</span> - <span class="ruby-identifier">best_candidate</span>=<span class="ruby-identifier">candidates</span>.<span class="ruby-identifier">sort</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">a</span>,<span class="ruby-identifier">b</span><span class="ruby-operator">|</span> <span class="ruby-identifier">b</span>.<span class="ruby-identifier">compatability_score</span><span class="ruby-operator">&lt;=&gt;</span><span class="ruby-identifier">a</span>.<span class="ruby-identifier">compatability_score</span>}[<span class="ruby-value">0</span>] - <span class="ruby-constant">RipXploreLog</span>.<span class="ruby-identifier">debug</span>(<span class="ruby-node">&quot;best candidate = #{best_candidate.file_system}/#{best_candidate.image_format} score: #{best_candidate.compatability_score}&quot;</span>) - <span class="ruby-identifier">best_candidate</span> + <span class="ruby-ivar">@compatability_score</span> <span class="ruby-keyword kw">end</span></pre> </body> </html> \ No newline at end of file