module FileData::ClassMethods

Class Methods

Defines behavior for subclasses of Flat::File regarding the management of its internal data structures.

Public Instance Methods

fields() click to toggle source

Convenience method for accessing flat_file_data[:fields]

Returns an Array of Field::Definitions

# File lib/flat/file_data.rb, line 39
def fields
  flat_file_data[:fields]
end
flat_file_data() click to toggle source

Container for various points of data as defined in the Flat::File subclass.

Returns a Hash with the following keys:

  • :width - The overall width, or length, of a line in the flat file.

  • :pack_format - A format String for use by String#unpack.

  • :fields - An Array of Field::Definitions

  • :layouts - An Array of Layout::Definitions

# File lib/flat/file_data.rb, line 25
def flat_file_data
  @data ||= {
    :width       => 0,
    :pack_format => '',
    :fields      => [],
    :layouts     => [],
  }
end
layouts() click to toggle source

Convenience method for accessing flat_file_data[:layouts]

Returns an Array of Layout::Definitions

# File lib/flat/file_data.rb, line 74
def layouts
  flat_file_data[:layout]
end
pack_format() click to toggle source

Convenience method for accessing flat_file_data[:pack_format]

Returns a String sutiable for use with String#unpack

# File lib/flat/file_data.rb, line 65
def pack_format
  flat_file_data[:pack_format]
end
width() click to toggle source

Convenience method for accessing flat_file_data[:width]

Returns the overall length of a line to text in the flat file.

# File lib/flat/file_data.rb, line 48
def width
  flat_file_data[:width]
end