Class | DataTable
In: | lib/data_table.rb
Parent: | Object

## What is it

Each EML document can contain DataTable 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. DataTable encapsulates data table elements from eml documents in the instance variable @metadata.

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.

## Examples

### Get the location where this data file is stored

      eml = metacat.find(:docid => 'somedoc.1.1')
      data_table = eml.data_tables[0]
      data_table.location
      => ecogrid://knb/pisco_cbs.30.3

### Write the data file to disk

      # note we are using a block so the whole file isn't loaded to RAM
      file = File.new("./tmp/#{data_table.id}")
      data_table.read do |buffer|
        file.write(buffer)
      end
      file.close

### Methods

columns data_format docid entity_name field_delimiter field_delimiter id location new num_headers physical read record_delimiter simple_delimited size text_format

### Attributes

eml | [R] |
metadata | [R] |

### Public Class methods

new(data_table_element, eml)

### Public Instance methods

columns()
data_format()
docid()

pulls the docid from distribution element

entity_name()
field_delimiter()
field_delimiter()
id()

refers to the docid function

location()

attribute reader for online distribution

num_headers()
physical()
read() {|f| ...}

reads the dataTable text from the url or docid specified by the physical/distribution/online/url entity

record_delimiter()
simple_delimited()
size()

only supports unit bytes

text_format()

[Validate]