<?xml version="1.0" encoding="iso-8859-1"?>
<!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>
  <title>Class: DataTable</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">DataTable</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../files/lib/data_table_rb.html">
                lib/data_table.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                Object
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <h2>What is it</h2>
<p>
Each EML document can contain <a href="DataTable.html">DataTable</a>
elements representing(in most cases) plain text data. The attributes of
this data, such as column names, types, domain info, are documented in the
eml metadata. <a href="DataTable.html">DataTable</a> encapsulates data
table elements from eml documents in the instance variable @metadata.
</p>
<p>
The purpose of this class is to provide methods to easily access metadata
attributes pertaining to the data table. It can also be extended for
specific applications to process the data based on the metadata
description.
</p>
<h2>Examples</h2>
<h3>Get the location where this data file is stored</h3>
<pre>
  eml = metacat.find(:docid =&gt; 'somedoc.1.1')
  data_table = eml.data_tables[0]
  data_table.location
  =&gt; ecogrid://knb/pisco_cbs.30.3
</pre>
<h3>Write the data file to disk</h3>
<pre>
  # note we are using a block so the whole file isn't loaded to RAM
  file = File.new(&quot;./tmp/#{data_table.id}&quot;)
  data_table.read do |buffer|
    file.write(buffer)
  end
  file.close
</pre>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000039">columns</a>&nbsp;&nbsp;
      <a href="#M000032">data_format</a>&nbsp;&nbsp;
      <a href="#M000027">docid</a>&nbsp;&nbsp;
      <a href="#M000040">entity_name</a>&nbsp;&nbsp;
      <a href="#M000033">field_delimiter</a>&nbsp;&nbsp;
      <a href="#M000038">field_delimiter</a>&nbsp;&nbsp;
      <a href="#M000028">id</a>&nbsp;&nbsp;
      <a href="#M000029">location</a>&nbsp;&nbsp;
      <a href="#M000026">new</a>&nbsp;&nbsp;
      <a href="#M000036">num_headers</a>&nbsp;&nbsp;
      <a href="#M000030">physical</a>&nbsp;&nbsp;
      <a href="#M000041">read</a>&nbsp;&nbsp;
      <a href="#M000037">record_delimiter</a>&nbsp;&nbsp;
      <a href="#M000035">simple_delimited</a>&nbsp;&nbsp;
      <a href="#M000031">size</a>&nbsp;&nbsp;
      <a href="#M000034">text_format</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





    <div id="attribute-list">
      <h3 class="section-bar">Attributes</h3>

      <div class="name-list">
        <table>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">eml</td>
          <td class="context-item-value">&nbsp;[R]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">metadata</td>
          <td class="context-item-value">&nbsp;[R]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        </table>
      </div>
    </div>
      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000026" class="method-detail">
        <a name="M000026"></a>

        <div class="method-heading">
          <a href="DataTable.src/M000026.html" target="Code" class="method-signature"
            onclick="popupCode('DataTable.src/M000026.html');return false;">
          <span class="method-name">new</span><span class="method-args">(data_table_element, eml)</span>
          </a>
        </div>
      
        <div class="method-description">
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000039" class="method-detail">
        <a name="M000039"></a>

        <div class="method-heading">
          <a href="DataTable.src/M000039.html" target="Code" class="method-signature"
            onclick="popupCode('DataTable.src/M000039.html');return false;">
          <span class="method-name">columns</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
        </div>
      </div>

      <div id="method-M000032" class="method-detail">
        <a name="M000032"></a>

        <div class="method-heading">
          <a href="DataTable.src/M000032.html" target="Code" class="method-signature"
            onclick="popupCode('DataTable.src/M000032.html');return false;">
          <span class="method-name">data_format</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
        </div>
      </div>

      <div id="method-M000027" class="method-detail">
        <a name="M000027"></a>

        <div class="method-heading">
          <a href="DataTable.src/M000027.html" target="Code" class="method-signature"
            onclick="popupCode('DataTable.src/M000027.html');return false;">
          <span class="method-name">docid</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
pulls the docid from distribution element
</p>
        </div>
      </div>

      <div id="method-M000040" class="method-detail">
        <a name="M000040"></a>

        <div class="method-heading">
          <a href="DataTable.src/M000040.html" target="Code" class="method-signature"
            onclick="popupCode('DataTable.src/M000040.html');return false;">
          <span class="method-name">entity_name</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
        </div>
      </div>

      <div id="method-M000033" class="method-detail">
        <a name="M000033"></a>

        <div class="method-heading">
          <a href="DataTable.src/M000033.html" target="Code" class="method-signature"
            onclick="popupCode('DataTable.src/M000033.html');return false;">
          <span class="method-name">field_delimiter</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
        </div>
      </div>

      <div id="method-M000038" class="method-detail">
        <a name="M000038"></a>

        <div class="method-heading">
          <a href="DataTable.src/M000038.html" target="Code" class="method-signature"
            onclick="popupCode('DataTable.src/M000038.html');return false;">
          <span class="method-name">field_delimiter</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
        </div>
      </div>

      <div id="method-M000028" class="method-detail">
        <a name="M000028"></a>

        <div class="method-heading">
          <a href="DataTable.src/M000028.html" target="Code" class="method-signature"
            onclick="popupCode('DataTable.src/M000028.html');return false;">
          <span class="method-name">id</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
refers to the docid function
</p>
        </div>
      </div>

      <div id="method-M000029" class="method-detail">
        <a name="M000029"></a>

        <div class="method-heading">
          <a href="DataTable.src/M000029.html" target="Code" class="method-signature"
            onclick="popupCode('DataTable.src/M000029.html');return false;">
          <span class="method-name">location</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
attribute reader for online distribution
</p>
        </div>
      </div>

      <div id="method-M000036" class="method-detail">
        <a name="M000036"></a>

        <div class="method-heading">
          <a href="DataTable.src/M000036.html" target="Code" class="method-signature"
            onclick="popupCode('DataTable.src/M000036.html');return false;">
          <span class="method-name">num_headers</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
        </div>
      </div>

      <div id="method-M000030" class="method-detail">
        <a name="M000030"></a>

        <div class="method-heading">
          <a href="DataTable.src/M000030.html" target="Code" class="method-signature"
            onclick="popupCode('DataTable.src/M000030.html');return false;">
          <span class="method-name">physical</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
        </div>
      </div>

      <div id="method-M000041" class="method-detail">
        <a name="M000041"></a>

        <div class="method-heading">
          <a href="DataTable.src/M000041.html" target="Code" class="method-signature"
            onclick="popupCode('DataTable.src/M000041.html');return false;">
          <span class="method-name">read</span><span class="method-args">() {|f| ...}</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
reads the dataTable text from the url or docid specified by the
physical/distribution/online/url entity
</p>
        </div>
      </div>

      <div id="method-M000037" class="method-detail">
        <a name="M000037"></a>

        <div class="method-heading">
          <a href="DataTable.src/M000037.html" target="Code" class="method-signature"
            onclick="popupCode('DataTable.src/M000037.html');return false;">
          <span class="method-name">record_delimiter</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
        </div>
      </div>

      <div id="method-M000035" class="method-detail">
        <a name="M000035"></a>

        <div class="method-heading">
          <a href="DataTable.src/M000035.html" target="Code" class="method-signature"
            onclick="popupCode('DataTable.src/M000035.html');return false;">
          <span class="method-name">simple_delimited</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
        </div>
      </div>

      <div id="method-M000031" class="method-detail">
        <a name="M000031"></a>

        <div class="method-heading">
          <a href="DataTable.src/M000031.html" target="Code" class="method-signature"
            onclick="popupCode('DataTable.src/M000031.html');return false;">
          <span class="method-name">size</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
only supports unit bytes
</p>
        </div>
      </div>

      <div id="method-M000034" class="method-detail">
        <a name="M000034"></a>

        <div class="method-heading">
          <a href="DataTable.src/M000034.html" target="Code" class="method-signature"
            onclick="popupCode('DataTable.src/M000034.html');return false;">
          <span class="method-name">text_format</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>