Permalink
Browse files

Added output of selected segments as CSV.

  • Loading branch information...
1 parent 1d25f3d commit 43329cb288baf6f7b7b727ba9bb29e2ced772452 @mikexstudios committed Jan 24, 2012
Showing with 11 additions and 3 deletions.
  1. +11 −3 cv_plot/cv_parser.rb
View
@@ -76,6 +76,14 @@ def get_segment(range = 0..-1) #default to full range
return @segments.slice(range)
end
+ def get_segment_as_csv(range = 0..-1) #default: full range
+ data = get_segment(range)
+
+ return data.map do |segment| #we may have multiple returned segments
+ segment.map { |point| point.to_csv }.join
+ end.join #join array elements to string
+ end
+
private
def calculate_potential_current_ranges
@@ -170,8 +178,8 @@ def determine_direction_of_scan(point1, point2)
if not segment_range.nil?
#1. Just one segment
if segment_range.index('..') #we find a range specification
- r = *(segment_range.split('..').map {|s| s.to_i})
- segment_range = Range.new(r)
+ r = segment_range.split('..').map {|s| s.to_i}
+ segment_range = Range.new(*r)
else
#2. Assume single integer
segment_range = segment_range.to_i
@@ -184,5 +192,5 @@ def determine_direction_of_scan(point1, point2)
cv = CVParser.new(cv_path)
cv.parse
- p cv.get_segment segment_range
+ puts cv.get_segment_as_csv segment_range
end

0 comments on commit 43329cb

Please sign in to comment.