Class: Symian::FileInputSequence
- Inherits:
-
Object
- Object
- Symian::FileInputSequence
- Defined in:
- lib/symian/generator.rb
Instance Method Summary collapse
-
#initialize(args) ⇒ FileInputSequence
constructor
A new instance of FileInputSequence.
-
#next ⇒ Object
returns nil when EOF occurs.
Constructor Details
#initialize(args) ⇒ FileInputSequence
Returns a new instance of FileInputSequence.
55 56 57 58 59 60 61 62 |
# File 'lib/symian/generator.rb', line 55 def initialize(args) @file = File.open(args[:path], 'r') # throw away the first line (containing the CSV headers) @file.gets @curr_val = args[:first_value] end |
Instance Method Details
#next ⇒ Object
returns nil when EOF occurs
65 66 67 68 69 70 71 72 |
# File 'lib/symian/generator.rb', line 65 def next displacement = @file.gets.try(:chomp).try(:to_f) return nil unless displacement ret = @curr_val @curr_val += displacement ret end |