class RGovData::FileDataSet

This is the catalog class that describes a generic file service DataSet Currently only handles text files

Public Instance Methods

attribute_value(row,attribute) click to toggle source

Returns the value of the named attribute from a recordset row Generic FileDataSets don’t have attributes, so always return full row

> overrides RGovData::DataSet.attribute_value

# File lib/rgovdata/service/dataset/file_dataset.rb, line 18
def attribute_value(row,attribute)
  row
end
attributes() click to toggle source

Returns array of attributes that describe the records of the specific entity Generic FileDataSets don’t have attributes, returns a single selector for the row

> overrides RGovData::Dn.attributes

# File lib/rgovdata/service/dataset/file_dataset.rb, line 11
def attributes
  ['row']
end

Protected Instance Methods

load_instance() click to toggle source

Loads the native dataset (URI or File)

> overrides RGovData::DataSet.load_instance

# File lib/rgovdata/service/dataset/file_dataset.rb, line 24
def load_instance
  if uri =~ /^.+:\/\//
    URI.parse( uri )
  else
    File.new(uri, "r")
  end
end
load_records() click to toggle source

Loads the native record set

> overrides RGovData::DataSet.load_records

# File lib/rgovdata/service/dataset/file_dataset.rb, line 35
def load_records
  # open(native_instance,"UserAgent" => "Mozilla/5.0")
  strio = StringIO.new(open(native_instance).read)
  if limit.present?
    strio.to_a[0,limit]
  else
    strio
  end
end