andywenk/page_performance

View on GitHub
doc/PagePerformance/Utils/FileRenamer.html

Summary

Maintainability
Test Coverage
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
  Class: PagePerformance::Utils::FileRenamer
  
    &mdash; Documentation by YARD 0.8.1
  
</title>

  <link rel="stylesheet" href="../../css/style.css" type="text/css" media="screen" charset="utf-8" />

  <link rel="stylesheet" href="../../css/common.css" type="text/css" media="screen" charset="utf-8" />

<script type="text/javascript" charset="utf-8">
  hasFrames = window.top.frames.main ? true : false;
  relpath = '../../';
  framesUrl = "../../frames.html#!" + escape(window.location.href);
</script>


  <script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>

  <script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>


  </head>
  <body>
    <div id="header">
      <div id="menu">
  
    <a href="../../_index.html">Index (F)</a> &raquo;
    <span class='title'><span class='object_link'><a href="../../PagePerformance.html" title="PagePerformance (module)">PagePerformance</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Utils.html" title="PagePerformance::Utils (module)">Utils</a></span></span>
     &raquo; 
    <span class="title">FileRenamer</span>
  

  <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
</div>

      <div id="search">
  
    <a class="full_list_link" id="class_list_link"
        href="../../class_list.html">
      Class List
    </a>
  
    <a class="full_list_link" id="method_list_link"
        href="../../method_list.html">
      Method List
    </a>
  
    <a class="full_list_link" id="file_list_link"
        href="../../file_list.html">
      File List
    </a>
  
</div>
      <div class="clear"></div>
    </div>

    <iframe id="search_frame"></iframe>

    <div id="content"><h1>Class: PagePerformance::Utils::FileRenamer
  
  
  
</h1>

<dl class="box">
  
    <dt class="r1">Inherits:</dt>
    <dd class="r1">
      <span class="inheritName">Object</span>
      
        <ul class="fullTree">
          <li>Object</li>
          
            <li class="next">PagePerformance::Utils::FileRenamer</li>
          
        </ul>
        <a href="#" class="inheritanceTree">show all</a>
      
      </dd>
    
  
  
    
  
    
  
  
  
    <dt class="r2 last">Defined in:</dt>
    <dd class="r2 last">lib/page_performance/utils/file_renamer.rb</dd>
  
</dl>
<div class="clear"></div>








  
    <h2>
      Instance Method Summary
      <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
    </h2>

    <ul class="summary">
      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#calculate_file_name_parts-instance_method" title="#calculate_file_name_parts (instance method)">- (Object) <strong>calculate_file_name_parts</strong> </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#calculate_path_parts-instance_method" title="#calculate_path_parts (instance method)">- (Object) <strong>calculate_path_parts</strong> </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#initialize-instance_method" title="#initialize (instance method)">- (FileRenamer) <strong>initialize</strong>(file_name) </a>
    

    
  </span>
  
  
    <span class="note title constructor">constructor</span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
A new instance of FileRenamer.
</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#new_file_with_path-instance_method" title="#new_file_with_path (instance method)">- (Object) <strong>new_file_with_path</strong> </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#rename-instance_method" title="#rename (instance method)">- (Object) <strong>rename</strong> </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
    </ul>
  

<div id="constructor_details" class="method_details_list">
  <h2>Constructor Details</h2>
  
    <div class="method_details first">
  <h3 class="signature first" id="initialize-instance_method">
  
    - (<tt><span class='object_link'><a href="" title="PagePerformance::Utils::FileRenamer (class)">FileRenamer</a></span></tt>) <strong>initialize</strong>(file_name) 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>
A new instance of FileRenamer
</p>


  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


4
5
6</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/page_performance/utils/file_renamer.rb', line 4</span>

<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_file_name'>file_name</span><span class='rparen'>)</span>
  <span class='ivar'>@file_name</span> <span class='op'>=</span> <span class='id identifier rubyid_file_name'>file_name</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
  
</div>


  <div id="instance_method_details" class="method_details_list">
    <h2>Instance Method Details</h2>

    
      <div class="method_details first">
  <h3 class="signature first" id="calculate_file_name_parts-instance_method">
  
    - (<tt>Object</tt>) <strong>calculate_file_name_parts</strong> 
  

  

  
</h3><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


31
32
33
34</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/page_performance/utils/file_renamer.rb', line 31</span>

<span class='kw'>def</span> <span class='id identifier rubyid_calculate_file_name_parts'>calculate_file_name_parts</span>
  <span class='id identifier rubyid_old_file_name'>old_file_name</span> <span class='op'>=</span> <span class='ivar'>@path_parts</span><span class='period'>.</span><span class='id identifier rubyid_slice!'>slice!</span><span class='lparen'>(</span><span class='op'>-</span><span class='int'>1</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_file_name_parts'>file_name_parts</span> <span class='op'>=</span> <span class='id identifier rubyid_old_file_name'>old_file_name</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>.</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="calculate_path_parts-instance_method">
  
    - (<tt>Object</tt>) <strong>calculate_path_parts</strong> 
  

  

  
</h3><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


18
19
20
21
22</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/page_performance/utils/file_renamer.rb', line 18</span>

<span class='kw'>def</span> <span class='id identifier rubyid_calculate_path_parts'>calculate_path_parts</span>
  <span class='id identifier rubyid_parts'>parts</span> <span class='op'>=</span> <span class='ivar'>@file_name</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>/</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
  <span class='id identifier rubyid_parts'>parts</span> <span class='op'>=</span> <span class='id identifier rubyid_parts'>parts</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span> <span class='lbrace'>{</span> <span class='op'>|</span> <span class='id identifier rubyid_item'>item</span> <span class='op'>|</span> <span class='id identifier rubyid_item'>item</span> <span class='kw'>unless</span> <span class='id identifier rubyid_item'>item</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_end'>&quot;</span></span> <span class='rbrace'>}</span>
  <span class='id identifier rubyid_parts'>parts</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="new_file_with_path-instance_method">
  
    - (<tt>Object</tt>) <strong>new_file_with_path</strong> 
  

  

  
</h3><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


24
25
26
27
28
29</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/page_performance/utils/file_renamer.rb', line 24</span>

<span class='kw'>def</span> <span class='id identifier rubyid_new_file_with_path'>new_file_with_path</span>
  <span class='id identifier rubyid_file_name_parts'>file_name_parts</span> <span class='op'>=</span> <span class='id identifier rubyid_calculate_file_name_parts'>calculate_file_name_parts</span>
  <span class='id identifier rubyid_new_number'>new_number</span> <span class='op'>=</span> <span class='id identifier rubyid_file_name_parts'>file_name_parts</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span> <span class='op'>+</span> <span class='int'>1</span>
  <span class='id identifier rubyid_new_file_name'>new_file_name</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='id identifier rubyid_file_name_parts'>file_name_parts</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_new_number'>new_number</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>.</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
  <span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='ivar'>@path_parts</span><span class='comma'>,</span> <span class='id identifier rubyid_new_file_name'>new_file_name</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>/</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="rename-instance_method">
  
    - (<tt>Object</tt>) <strong>rename</strong> 
  

  

  
</h3><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


8
9
10
11
12
13
14
15
16</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/page_performance/utils/file_renamer.rb', line 8</span>

<span class='kw'>def</span> <span class='id identifier rubyid_rename'>rename</span>
  <span class='ivar'>@path_parts</span> <span class='op'>=</span> <span class='id identifier rubyid_calculate_path_parts'>calculate_path_parts</span>
  <span class='id identifier rubyid_new_file'>new_file</span> <span class='op'>=</span> <span class='id identifier rubyid_new_file_with_path'>new_file_with_path</span>
  <span class='kw'>if</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_exist?'>exist?</span><span class='lparen'>(</span><span class='id identifier rubyid_new_file'>new_file</span><span class='rparen'>)</span>
    <span class='ivar'>@file_name</span> <span class='op'>=</span> <span class='id identifier rubyid_new_file'>new_file</span>
    <span class='id identifier rubyid_new_file'>new_file</span> <span class='op'>=</span> <span class='id identifier rubyid_rename'>rename</span>
  <span class='kw'>end</span>
  <span class='id identifier rubyid_new_file'>new_file</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
  </div>

</div>

    <div id="footer">
  Generated on Mon May 28 22:28:00 2012 by
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
  0.8.1 (ruby-1.9.2).
</div>

  </body>
</html>