ShogunPanda/lazier

View on GitHub
docs/Lazier/TimeZone/ClassMethods.html

Summary

Maintainability
Test Coverage
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
  Module: Lazier::TimeZone::ClassMethods
  
    &mdash; Documentation by YARD 0.9.5
  
</title>

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

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

<script type="text/javascript" charset="utf-8">
  pathId = "Lazier::TimeZone::ClassMethods";
  relpath = '../../';
</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 class="nav_wrap">
      <iframe id="nav" src="../../class_list.html"></iframe>
      <div id="resizer"></div>
    </div>

    <div id="main" tabindex="-1">
      <div id="header">
        <div id="menu">
  
    <a href="../../_index.html">Index (C)</a> &raquo;
    <span class='title'><span class='object_link'><a href="../../Lazier.html" title="Lazier (module)">Lazier</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../TimeZone.html" title="Lazier::TimeZone (module)">TimeZone</a></span></span>
     &raquo; 
    <span class="title">ClassMethods</span>
  
</div>

        <div id="search">
  
    <a class="full_list_link" id="class_list_link"
        href="../../class_list.html">

        <svg width="24" height="24">
          <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
          <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
          <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
        </svg>
    </a>
  
</div>
        <div class="clear"></div>
      </div>

      <iframe id="search_frame" src="../../class_list.html"></iframe>

      <div id="content"><h1>Module: Lazier::TimeZone::ClassMethods
  
  
  
</h1>
<div class="box_info">
  

  
  
  
  
  

  

  
  <dl>
    <dt>Defined in:</dt>
    <dd>lib/lazier/timezone.rb</dd>
  </dl>
  
</div>

<h2>Overview</h2><div class="docstring">
  <div class="discussion">
    <p>General methods.</p>


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

</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="#compare-instance_method" title="#compare (instance method)">#<strong>compare</strong>(left, right)  &#x21d2; Fixnum </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Compares two timezones.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#find-instance_method" title="#find (instance method)">#<strong>find</strong>(name, dst_label = &quot; (DST)&quot;)  &#x21d2; TimeZone </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Find a zone by its name.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#format_offset-instance_method" title="#format_offset (instance method)">#<strong>format_offset</strong>(offset, colon = true)  &#x21d2; String </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Returns a +HH:MM formatted representation of the offset.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#list-instance_method" title="#list (instance method)">#<strong>list</strong>(with_dst = true, dst_label: &quot; (DST)&quot;, parameterized: false, sort_by_name: true, as_hash: false)  &#x21d2; Array|Hash </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Returns a list of names of all timezones.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#parameterize-instance_method" title="#parameterize (instance method)">#<strong>parameterize</strong>(tz, with_offset = true)  &#x21d2; String </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Returns a string representation of a timezone.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#rationalize_offset-instance_method" title="#rationalize_offset (instance method)">#<strong>rationalize_offset</strong>(offset)  &#x21d2; Rational </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Expression to parameterize a zone Returns an offset in rational value.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#unparameterize-instance_method" title="#unparameterize (instance method)">#<strong>unparameterize</strong>(tz, dst_label = &quot; (DST)&quot;)  &#x21d2; TimeZone </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Finds a parameterized timezone.</p>
</div></span>
  
</li>

      
    </ul>
  



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

    
      <div class="method_details first">
  <h3 class="signature first" id="compare-instance_method">
  
    #<strong>compare</strong>(left, right)  &#x21d2; <tt>Fixnum</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Compares two timezones. They are sorted by the location name.</p>


  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>left</span>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="../String.html" title="Lazier::String (module)">String</a></span>|<span class='object_link'><a href="../TimeZone.html" title="Lazier::TimeZone (module)">TimeZone</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The first zone name to compare.</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>right</span>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="../String.html" title="Lazier::String (module)">String</a></span>|<span class='object_link'><a href="../TimeZone.html" title="Lazier::TimeZone (module)">TimeZone</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The second zone name to compare.</p>
</div>
      
    </li>
  
</ul>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Fixnum</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The result of comparison, like Ruby’s operator <code>&lt;=&gt;</code>.</p>
</div>
      
    </li>
  
</ul>

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


112
113
114
115
116</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/lazier/timezone.rb', line 112</span>

<span class='kw'>def</span> <span class='id identifier rubyid_compare'>compare</span><span class='lparen'>(</span><span class='id identifier rubyid_left'>left</span><span class='comma'>,</span> <span class='id identifier rubyid_right'>right</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_left'>left</span> <span class='op'>=</span> <span class='id identifier rubyid_left'>left</span><span class='period'>.</span><span class='id identifier rubyid_to_str'>to_str</span> <span class='kw'>if</span> <span class='id identifier rubyid_left'>left</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>ActiveSupport</span><span class='op'>::</span><span class='const'>TimeZone</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_right'>right</span> <span class='op'>=</span> <span class='id identifier rubyid_right'>right</span><span class='period'>.</span><span class='id identifier rubyid_to_str'>to_str</span> <span class='kw'>if</span> <span class='id identifier rubyid_right'>right</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>ActiveSupport</span><span class='op'>::</span><span class='const'>TimeZone</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_left'>left</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</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='int'>2</span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>&lt;=&gt;</span> <span class='id identifier rubyid_right'>right</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</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='int'>2</span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="find-instance_method">
  
    #<strong>find</strong>(name, dst_label = &quot; (DST)&quot;)  &#x21d2; <tt><span class='object_link'><a href="../TimeZone.html" title="Lazier::TimeZone (module)">TimeZone</a></span></tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Find a zone by its name.</p>


  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>name</span>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="../String.html" title="Lazier::String (module)">String</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The zone name.</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>dst_label</span>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="../String.html" title="Lazier::String (module)">String</a></span></tt>)</span>
      
      
        <em class="default">(defaults to: <tt>&quot; (DST)&quot;</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>Label for the DST indication. Defaults to ` (DST)`.</p>
</div>
      
    </li>
  
</ul>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="../TimeZone.html" title="Lazier::TimeZone (module)">TimeZone</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>A timezone or <code>nil</code> if no zone was found.</p>
</div>
      
    </li>
  
</ul>

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


48
49
50
51
52</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/lazier/timezone.rb', line 48</span>

<span class='kw'>def</span> <span class='id identifier rubyid_find'>find</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_dst_label'>dst_label</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'> (DST)</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
  <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_list'>list</span><span class='lparen'>(</span><span class='kw'>true</span><span class='comma'>,</span> <span class='label'>dst_label:</span> <span class='id identifier rubyid_dst_label'>dst_label</span><span class='comma'>,</span> <span class='label'>as_hash:</span> <span class='kw'>true</span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span>
  <span class='id identifier rubyid_rv'>rv</span><span class='period'>.</span><span class='id identifier rubyid_current_alias'>current_alias</span> <span class='op'>=</span> <span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\(GMT(.{6})\) (.+)(</span><span class='embexpr_beg'>#{</span><span class='const'>Regexp</span><span class='period'>.</span><span class='id identifier rubyid_quote'>quote</span><span class='lparen'>(</span><span class='id identifier rubyid_dst_label'>dst_label</span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_content'>)$</span><span class='regexp_end'>/</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\\2</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span>
  <span class='id identifier rubyid_rv'>rv</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="format_offset-instance_method">
  
    #<strong>format_offset</strong>(offset, colon = true)  &#x21d2; <tt><span class='object_link'><a href="../String.html" title="Lazier::String (module)">String</a></span></tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Returns a +HH:MM formatted representation of the offset.</p>


  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>offset</span>
      
      
        <span class='type'>(<tt>Rational|Fixnum</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The offset to represent, in seconds or as a rational.</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>colon</span>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="../Boolean.html" title="Lazier::Boolean (module)">Boolean</a></span></tt>)</span>
      
      
        <em class="default">(defaults to: <tt>true</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>Whether to put the colon in the output string.</p>
</div>
      
    </li>
  
</ul>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="../String.html" title="Lazier::String (module)">String</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The formatted offset.</p>
</div>
      
    </li>
  
</ul>

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


39
40
41</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/lazier/timezone.rb', line 39</span>

<span class='kw'>def</span> <span class='id identifier rubyid_format_offset'>format_offset</span><span class='lparen'>(</span><span class='id identifier rubyid_offset'>offset</span><span class='comma'>,</span> <span class='id identifier rubyid_colon'>colon</span> <span class='op'>=</span> <span class='kw'>true</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_seconds_to_utc_offset'>seconds_to_utc_offset</span><span class='lparen'>(</span><span class='id identifier rubyid_offset'>offset</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Rational</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='lparen'>(</span><span class='id identifier rubyid_offset'>offset</span> <span class='op'>*</span> <span class='int'>86_400</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span> <span class='op'>:</span> <span class='id identifier rubyid_offset'>offset</span><span class='comma'>,</span> <span class='id identifier rubyid_colon'>colon</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="list-instance_method">
  
    #<strong>list</strong>(with_dst = true, dst_label: &quot; (DST)&quot;, parameterized: false, sort_by_name: true, as_hash: false)  &#x21d2; <tt>Array|<span class='object_link'><a href="../Hash.html" title="Lazier::Hash (module)">Hash</a></span></tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Returns a list of names of all timezones.</p>


  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>with_dst</span>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="../Boolean.html" title="Lazier::Boolean (module)">Boolean</a></span></tt>)</span>
      
      
        <em class="default">(defaults to: <tt>true</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>If include DST version of the zones.</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>parameterized</span>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="../Boolean.html" title="Lazier::Boolean (module)">Boolean</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>If parameterize zones.</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>dst_label</span>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="../String.html" title="Lazier::String (module)">String</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>Label for the DST indication. Defaults to ` (DST)`.</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>as_hash</span>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="../Hash.html" title="Lazier::Hash (module)">Hash</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>If return an hash.</p>
</div>
      
    </li>
  
</ul>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Array|<span class='object_link'><a href="../Hash.html" title="Lazier::Hash (module)">Hash</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>A list of names of timezones or a hash with labels and timezones as keys.</p>
</div>
      
    </li>
  
</ul>

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


61
62
63
64
65
66
67
68
69
70
71
72</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/lazier/timezone.rb', line 61</span>

<span class='kw'>def</span> <span class='id identifier rubyid_list'>list</span><span class='lparen'>(</span><span class='id identifier rubyid_with_dst'>with_dst</span> <span class='op'>=</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>dst_label:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'> (DST)</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>parameterized:</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='label'>sort_by_name:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>as_hash:</span> <span class='kw'>false</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_dst_label'>dst_label</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='id identifier rubyid_with_dst'>with_dst</span>
  <span class='id identifier rubyid_key'>key</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='id identifier rubyid_dst_label'>dst_label</span><span class='comma'>,</span> <span class='id identifier rubyid_sort_by_name'>sort_by_name</span><span class='comma'>,</span> <span class='id identifier rubyid_as_hash'>as_hash</span><span class='comma'>,</span> <span class='id identifier rubyid_parameterized'>parameterized</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'>&quot;</span><span class='tstring_content'>:</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
  <span class='ivar'>@zones_names</span> <span class='op'>||=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>

  <span class='kw'>unless</span> <span class='ivar'>@zones_names</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span>
    <span class='id identifier rubyid_all'>all</span> <span class='op'>=</span> <span class='op'>::</span><span class='const'>ActiveSupport</span><span class='op'>::</span><span class='const'>TimeZone</span><span class='period'>.</span><span class='id identifier rubyid_all'>all</span>
    <span class='ivar'>@zones_names</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_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>finalize_list_as_</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_as_hash'>as_hash</span> <span class='op'>?</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>hash</span><span class='tstring_end'>&quot;</span></span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>list</span><span class='tstring_end'>&quot;</span></span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_all'>all</span><span class='comma'>,</span> <span class='id identifier rubyid_dst_label'>dst_label</span><span class='comma'>,</span> <span class='id identifier rubyid_parameterized'>parameterized</span><span class='comma'>,</span> <span class='id identifier rubyid_sort_by_name'>sort_by_name</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='ivar'>@zones_names</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="parameterize-instance_method">
  
    #<strong>parameterize</strong>(tz, with_offset = true)  &#x21d2; <tt><span class='object_link'><a href="../String.html" title="Lazier::String (module)">String</a></span></tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Returns a string representation of a timezone.</p>

<p><code>ruby
DateTime.parameterize_zone(ActiveSupport::TimeZone["Pacific Time (US &amp; Canada)"])
# =&gt; "-0800@pacific-time-us-canada"
</code></p>


  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>tz</span>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="../TimeZone.html" title="Lazier::TimeZone (module)">TimeZone</a></span>|<span class='object_link'><a href="../String.html" title="Lazier::String (module)">String</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The zone to represent.</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>with_offset</span>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="../Boolean.html" title="Lazier::Boolean (module)">Boolean</a></span></tt>)</span>
      
      
        <em class="default">(defaults to: <tt>true</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>Whether to include offset into the representation.</p>
</div>
      
    </li>
  
</ul>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="../String.html" title="Lazier::String (module)">String</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>A string representation which can be used for searches.</p>
</div>
      
    </li>
  
</ul>

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


83
84
85
86
87
88
89
90
91
92
93
94</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/lazier/timezone.rb', line 83</span>

<span class='kw'>def</span> <span class='id identifier rubyid_parameterize'>parameterize</span><span class='lparen'>(</span><span class='id identifier rubyid_tz'>tz</span><span class='comma'>,</span> <span class='id identifier rubyid_with_offset'>with_offset</span> <span class='op'>=</span> <span class='kw'>true</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_tz'>tz</span> <span class='op'>=</span> <span class='id identifier rubyid_tz'>tz</span><span class='period'>.</span><span class='id identifier rubyid_to_str'>to_str</span> <span class='kw'>unless</span> <span class='id identifier rubyid_tz'>tz</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>String</span><span class='rparen'>)</span>

  <span class='kw'>if</span> <span class='id identifier rubyid_tz'>tz</span> <span class='op'>=~</span> <span class='op'>::</span><span class='const'>Lazier</span><span class='op'>::</span><span class='const'>TimeZone</span><span class='op'>::</span><span class='const'>ALREADY_PARAMETERIZED</span>
    <span class='id identifier rubyid_tz'>tz</span>
  <span class='kw'>elsif</span> <span class='id identifier rubyid_tz'>tz</span> <span class='op'>=~</span> <span class='op'>::</span><span class='const'>Lazier</span><span class='op'>::</span><span class='const'>TimeZone</span><span class='op'>::</span><span class='const'>PARAMETERIZER</span>
    <span class='id identifier rubyid_mo'>mo</span> <span class='op'>=</span> <span class='gvar'>$LAST_MATCH_INFO</span>
    <span class='lbracket'>[</span><span class='lparen'>(</span><span class='id identifier rubyid_with_offset'>with_offset</span> <span class='op'>?</span> <span class='id identifier rubyid_mo'>mo</span><span class='lbracket'>[</span><span class='symbol'>:offset</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</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='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>nil</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_mo'>mo</span><span class='lbracket'>[</span><span class='symbol'>:label</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_parameterize'>parameterize</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>@</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
  <span class='kw'>else</span>
    <span class='id identifier rubyid_tz'>tz</span><span class='period'>.</span><span class='id identifier rubyid_parameterize'>parameterize</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="rationalize_offset-instance_method">
  
    #<strong>rationalize_offset</strong>(offset)  &#x21d2; <tt>Rational</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Expression to parameterize a zone
Returns an offset in rational value.</p>


  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>offset</span>
      
      
        <span class='type'>(<tt>Fixnum</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The offset to convert.</p>
</div>
      
    </li>
  
</ul>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Rational</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The converted offset.</p>
</div>
      
    </li>
  
</ul>

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


30
31
32</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/lazier/timezone.rb', line 30</span>

<span class='kw'>def</span> <span class='id identifier rubyid_rationalize_offset'>rationalize_offset</span><span class='lparen'>(</span><span class='id identifier rubyid_offset'>offset</span><span class='rparen'>)</span>
  <span class='op'>::</span><span class='const'>TZInfo</span><span class='op'>::</span><span class='const'>OffsetRationals</span><span class='period'>.</span><span class='id identifier rubyid_rational_for_offset'>rational_for_offset</span><span class='lparen'>(</span><span class='id identifier rubyid_offset'>offset</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="unparameterize-instance_method">
  
    #<strong>unparameterize</strong>(tz, dst_label = &quot; (DST)&quot;)  &#x21d2; <tt><span class='object_link'><a href="../TimeZone.html" title="Lazier::TimeZone (module)">TimeZone</a></span></tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Finds a parameterized timezone.</p>


  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>tz</span>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="../String.html" title="Lazier::String (module)">String</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The zone to unparameterize.</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>dst_label</span>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="../String.html" title="Lazier::String (module)">String</a></span></tt>)</span>
      
      
        <em class="default">(defaults to: <tt>&quot; (DST)&quot;</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>Label for the DST indication. Defaults to <code>(DST)</code>.</p>
</div>
      
    </li>
  
</ul>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="../TimeZone.html" title="Lazier::TimeZone (module)">TimeZone</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The found timezone or <code>nil</code> if the zone is not valid.</p>
</div>
      
    </li>
  
</ul>

  <p class="tag_title">See Also:</p>
  <ul class="see">
    
      <li>DateTime#parameterize_zone</li>
    
  </ul>

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


102
103
104
105</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/lazier/timezone.rb', line 102</span>

<span class='kw'>def</span> <span class='id identifier rubyid_unparameterize'>unparameterize</span><span class='lparen'>(</span><span class='id identifier rubyid_tz'>tz</span><span class='comma'>,</span> <span class='id identifier rubyid_dst_label'>dst_label</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'> (DST)</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
  <span class='id identifier rubyid_tz'>tz</span> <span class='op'>=</span> <span class='id identifier rubyid_parameterize'>parameterize</span><span class='lparen'>(</span><span class='id identifier rubyid_tz'>tz</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_list'>list</span><span class='lparen'>(</span><span class='kw'>true</span><span class='comma'>,</span> <span class='label'>dst_label:</span> <span class='id identifier rubyid_dst_label'>dst_label</span><span class='comma'>,</span> <span class='label'>parameterized:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>as_hash:</span> <span class='kw'>true</span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='id identifier rubyid_tz'>tz</span><span class='rbracket'>]</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
  </div>

</div>

      <div id="footer">
  Generated on Thu Nov 10 11:39:24 2016 by
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
  0.9.5 (ruby-2.3.0).
</div>

    </div>
  </body>
</html>