Class: ActiveNutrition::Utilities::DataFile

Inherits:
Object
  • Object
show all
Defined in:
lib/active_nutrition/utilities/data_file.rb

Constant Summary collapse

FIELD_SEP =
'^'
FIELD_ENC =
'~'
NULL_FIELDS =
['^^', '~~', "\r\n", '']

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ DataFile

Returns a new instance of DataFile.



12
13
14
15
# File 'lib/active_nutrition/utilities/data_file.rb', line 12

def initialize(file)
  @file = file
  @handle = File.open(file, "r")
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



6
7
8
# File 'lib/active_nutrition/utilities/data_file.rb', line 6

def file
  @file
end

#handleObject (readonly)

Returns the value of attribute handle.



6
7
8
# File 'lib/active_nutrition/utilities/data_file.rb', line 6

def handle
  @handle
end

Instance Method Details

#eachObject



17
18
19
20
21
22
# File 'lib/active_nutrition/utilities/data_file.rb', line 17

def each
  @handle.each do |line|
    yield self.parse_line(line)
  end
  self.clean_up
end