Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions lib/fixedwidth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,20 @@ def self.parse(options)
@semaphore ||= Mutex.new # This wouldn't be necessary if this was turned
@semaphore.synchronize do # into a class instead of a module
setup(options)
if block_given?
File.open(@options[:file]).each_line do |line|
if @options[:file].present?
if block_given?
File.open(@options[:file]).each_line do |line|
yield Line.new(line)
end
else
raise
end
elsif @options[:string].present?
@options[:string].each_line do |line|
yield Line.new(line)
end
else
raise
end
end
end
Expand Down