HEX
Server: Apache
System: Windows NT MAGNETO-ARM 10.0 build 22000 (Windows 10) AMD64
User: Michel (0)
PHP: 7.4.7
Disabled: NONE
Upload Files
File: C:/Ruby27-x64/share/doc/ruby/html/PrettyPrint/SingleLine.html
<!DOCTYPE html>

<html>
<head>
<meta charset="UTF-8">

<title>class PrettyPrint::SingleLine - RDoc Documentation</title>

<script type="text/javascript">
  var rdoc_rel_prefix = "../";
  var index_rel_prefix = "../";
</script>

<script src="../js/navigation.js" defer></script>
<script src="../js/search.js" defer></script>
<script src="../js/search_index.js" defer></script>
<script src="../js/searcher.js" defer></script>
<script src="../js/darkfish.js" defer></script>

<link href="../css/fonts.css" rel="stylesheet">
<link href="../css/rdoc.css" rel="stylesheet">




<body id="top" role="document" class="class">
<nav role="navigation">
  <div id="project-navigation">
    <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2>
    <a href="../index.html" rel="home">Home</a>
  </h2>

  <div id="table-of-contents-navigation">
    <a href="../table_of_contents.html#pages">Pages</a>
    <a href="../table_of_contents.html#classes">Classes</a>
    <a href="../table_of_contents.html#methods">Methods</a>
  </div>
</div>

    <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

  </div>

  

  <div id="class-metadata">
    
    <div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  
  <p class="link"><a href="../Object.html">Object</a>
  
</div>

    
    
    <!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    
    <li ><a href="#method-c-new">::new</a>
    
    <li ><a href="#method-i-breakable">#breakable</a>
    
    <li ><a href="#method-i-first-3F">#first?</a>
    
    <li ><a href="#method-i-group">#group</a>
    
    <li ><a href="#method-i-text">#text</a>
    
  </ul>
</div>

  </div>
</nav>

<main role="main" aria-labelledby="class-PrettyPrint::SingleLine">
  <h1 id="class-PrettyPrint::SingleLine" class="class">
    class PrettyPrint::SingleLine
  </h1>

  <section class="description">
    
<p><a href="SingleLine.html"><code>PrettyPrint::SingleLine</code></a> is used by <a href="../PrettyPrint.html#method-c-singleline_format"><code>PrettyPrint.singleline_format</code></a></p>

<p>It is passed to be similar to a <a href="../PrettyPrint.html"><code>PrettyPrint</code></a> object itself, by responding to:</p>
<ul><li>
<p><a href="SingleLine.html#method-i-text"><code>text</code></a></p>
</li><li>
<p><a href="SingleLine.html#method-i-breakable"><code>breakable</code></a></p>
</li><li>
<p>nest</p>
</li><li>
<p><a href="SingleLine.html#method-i-group"><code>group</code></a></p>
</li><li>
<p>flush</p>
</li><li>
<p><a href="SingleLine.html#method-i-first-3F"><code>first?</code></a></p>
</li></ul>

<p>but instead, the output has no line breaks</p>

  </section>

  
  <section id="5Buntitled-5D" class="documentation-section">
    

    

    

    

    
     <section id="public-class-5Buntitled-5D-method-details" class="method-section">
       <header>
         <h3>Public Class Methods</h3>
       </header>

    
      <div id="method-c-new" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">new</span><span
            class="method-args">(output, maxwidth=nil, newline=nil)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Create a <a href="SingleLine.html"><code>PrettyPrint::SingleLine</code></a> object</p>

<p>Arguments:</p>
<ul><li>
<p><code>output</code> - <a href="../String.html"><code>String</code></a> (or similar) to store rendered text. Needs to respond to &#39;&lt;&lt;&#39;</p>
</li><li>
<p><code>maxwidth</code> - Argument position expected to be here for compatibility.</p>

<pre>This argument is a noop.</pre>
</li><li>
<p><code>newline</code> - Argument position expected to be here for compatibility.</p>

<pre>This argument is a noop.</pre>
</li></ul>
          
          

          
          <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File lib/prettyprint.rb, line 503</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">output</span>, <span class="ruby-identifier">maxwidth</span>=<span class="ruby-keyword">nil</span>, <span class="ruby-identifier">newline</span>=<span class="ruby-keyword">nil</span>)
  <span class="ruby-ivar">@output</span> = <span class="ruby-identifier">output</span>
  <span class="ruby-ivar">@first</span> = [<span class="ruby-keyword">true</span>]
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
    </section>
  
     <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
       <header>
         <h3>Public Instance Methods</h3>
       </header>

    
      <div id="method-i-breakable" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">breakable</span><span
            class="method-args">(sep=&#39; &#39;, width=nil)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Appends <code>sep</code> to the text to be output. By default <code>sep</code> is &#39; &#39;</p>

<p><code>width</code> argument is here for compatibility. It is a noop argument.</p>
          
          

          
          <div class="method-source-code" id="breakable-source">
            <pre><span class="ruby-comment"># File lib/prettyprint.rb, line 518</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">breakable</span>(<span class="ruby-identifier">sep</span>=<span class="ruby-string">&#39; &#39;</span>, <span class="ruby-identifier">width</span>=<span class="ruby-keyword">nil</span>)
  <span class="ruby-ivar">@output</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">sep</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-first-3F" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">first?</span><span
            class="method-args">()</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>This is used as a predicate, and ought to be called first.</p>
          
          

          
          <div class="method-source-code" id="first-3F-source">
            <pre><span class="ruby-comment"># File lib/prettyprint.rb, line 550</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">first?</span>
  <span class="ruby-identifier">result</span> = <span class="ruby-ivar">@first</span>[<span class="ruby-value">-1</span>]
  <span class="ruby-ivar">@first</span>[<span class="ruby-value">-1</span>] = <span class="ruby-keyword">false</span>
  <span class="ruby-identifier">result</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-group" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">group</span><span
            class="method-args">(indent=nil, open_obj=&#39;&#39;, close_obj=&#39;&#39;, open_width=nil, close_width=nil) { || ... }</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Opens a block for grouping objects to be pretty printed.</p>

<p>Arguments:</p>
<ul><li>
<p><code>indent</code> - noop argument. Present for compatibility.</p>
</li><li>
<p><code>open_obj</code> - text appended before the &amp;blok. Default is &#39;&#39;</p>
</li><li>
<p><code>close_obj</code> - text appended after the &amp;blok. Default is &#39;&#39;</p>
</li><li>
<p><code>open_width</code> - noop argument. Present for compatibility.</p>
</li><li>
<p><code>close_width</code> - noop argument. Present for compatibility.</p>
</li></ul>
          
          

          
          <div class="method-source-code" id="group-source">
            <pre><span class="ruby-comment"># File lib/prettyprint.rb, line 537</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">group</span>(<span class="ruby-identifier">indent</span>=<span class="ruby-keyword">nil</span>, <span class="ruby-identifier">open_obj</span>=<span class="ruby-string">&#39;&#39;</span>, <span class="ruby-identifier">close_obj</span>=<span class="ruby-string">&#39;&#39;</span>, <span class="ruby-identifier">open_width</span>=<span class="ruby-keyword">nil</span>, <span class="ruby-identifier">close_width</span>=<span class="ruby-keyword">nil</span>)
  <span class="ruby-ivar">@first</span>.<span class="ruby-identifier">push</span> <span class="ruby-keyword">true</span>
  <span class="ruby-ivar">@output</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">open_obj</span>
  <span class="ruby-keyword">yield</span>
  <span class="ruby-ivar">@output</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">close_obj</span>
  <span class="ruby-ivar">@first</span>.<span class="ruby-identifier">pop</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-text" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">text</span><span
            class="method-args">(obj, width=nil)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Add <code>obj</code> to the text to be output.</p>

<p><code>width</code> argument is here for compatibility. It is a noop argument.</p>
          
          

          
          <div class="method-source-code" id="text-source">
            <pre><span class="ruby-comment"># File lib/prettyprint.rb, line 511</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">text</span>(<span class="ruby-identifier">obj</span>, <span class="ruby-identifier">width</span>=<span class="ruby-keyword">nil</span>)
  <span class="ruby-ivar">@output</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">obj</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
    </section>
  
  </section>

</main>


<footer id="validator-badges" role="contentinfo">
  <p><a href="https://validator.w3.org/check/referer">Validate</a>
  <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.1.1.
  <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
</footer>