Class: ActiveNutrition::Utilities::DataFile
- Inherits:
-
Object
- Object
- ActiveNutrition::Utilities::DataFile
- Defined in:
- lib/active_nutrition/utilities/data_file.rb
Constant Summary collapse
- FIELD_SEP =
'^'
- FIELD_ENC =
'~'
- NULL_FIELDS =
['^^', '~~', "\r\n", '']
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#handle ⇒ Object
readonly
Returns the value of attribute handle.
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(file) ⇒ DataFile
constructor
A new instance of DataFile.
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
#file ⇒ Object (readonly)
Returns the value of attribute file.
6 7 8 |
# File 'lib/active_nutrition/utilities/data_file.rb', line 6 def file @file end |
#handle ⇒ Object (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
#each ⇒ Object
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 |