Module: FileData::ClassMethods
- Defined in:
- lib/flat/file_data.rb
Overview
Class Methods
Defines behavior for subclasses of Flat::File regarding the management of its internal data structures.
Instance Method Summary collapse
-
#fields ⇒ Object
Convenience method for accessing
flat_file_data[:fields]
. -
#flat_file_data ⇒ Object
Container for various points of data as defined in the Flat::File subclass.
-
#layouts ⇒ Object
Convenience method for accessing
flat_file_data[:layouts]
. -
#pack_format ⇒ Object
Convenience method for accessing
flat_file_data[:pack_format]
. -
#reset_file_data ⇒ Object
Added for test purposes, primarily.
-
#width ⇒ Object
Convenience method for accessing
flat_file_data[:width]
. -
#width=(value) ⇒ Object
Added setter to support +=, -= constructs; also allows direct assignment.
Instance Method Details
#fields ⇒ Object
Convenience method for accessing flat_file_data[:fields]
Returns an Array
of Field::Definitions
39 40 41 |
# File 'lib/flat/file_data.rb', line 39 def fields flat_file_data[:fields] end |
#flat_file_data ⇒ Object
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 formatString
for use by String#unpack. -
:fields
- AnArray
of Field::Definitions -
:layouts
- AnArray
of Layout::Definitions
25 26 27 28 29 30 31 32 |
# File 'lib/flat/file_data.rb', line 25 def flat_file_data @data ||= { :width => 0, :pack_format => '', :fields => [], :layouts => [], } end |
#layouts ⇒ Object
Convenience method for accessing flat_file_data[:layouts]
Returns an Array
of Layout::Definitions
74 75 76 |
# File 'lib/flat/file_data.rb', line 74 def layouts flat_file_data[:layout] end |
#pack_format ⇒ Object
Convenience method for accessing flat_file_data[:pack_format]
Returns a String
sutiable for use with String#unpack
65 66 67 |
# File 'lib/flat/file_data.rb', line 65 def pack_format flat_file_data[:pack_format] end |
#reset_file_data ⇒ Object
Added for test purposes, primarily. DESTRUCTIVE!
81 82 83 |
# File 'lib/flat/file_data.rb', line 81 def reset_file_data #:nodoc: @data = nil end |
#width ⇒ Object
Convenience method for accessing flat_file_data[:width]
Returns the overall length of a line to text in the flat file.
48 49 50 |
# File 'lib/flat/file_data.rb', line 48 def width flat_file_data[:width] end |
#width=(value) ⇒ Object
Added setter to support +=, -= constructs; also allows direct assignment.
56 57 58 |
# File 'lib/flat/file_data.rb', line 56 def width=(value) #:nodoc: flat_file_data[:width] = value end |