class CommaSplice::VariableColumnFinder
playid,playtype,genre,timestamp,artist,title,albumtitle,label,prepost,programtype,iswebcast,isrequest 17385098,,,01-27-2019 @ 13:58:00,Niney & Soul Syndicate,So Long Dub,Dub Box Set Vol. 2,Trojan,post,live,y, 17385097,,,01-27-2019 @ 13:57:00,King Tubby,Love Thy Neighbor,Jesus Dread,Blood & Fire,post,live,y, 17385096,,,01-27-2019 @ 13:53:00,King Tubby / The Aggrovators,Declaration Of Dub,Dub From The Roots,Charly,post,live,y, 17385095,,,01-27-2019 @ 13:50:00,Harry Mudie / King Tubby,Dub With A Difference,In Dub Conference Vol. 1,Moodisc,post,live,y, 17385094,,,01-27-2019 @ 13:47:00,KIng Tubby Meets The Upsetter,King And The Upsetter At Spanish Town,KIng Tubby Meets The Upsetter,Celluloid,post,live,y,
Attributes
end_column[R]
start_column[R]
Public Class Methods
new(header_line, value_lines)
click to toggle source
# File lib/comma_splice/helpers/variable_column_finder.rb, line 23 def initialize(header_line, value_lines) @values = value_lines @header = header_line find_variable_column_boundaries end
Public Instance Methods
find_variable_column_boundaries()
click to toggle source
# File lib/comma_splice/helpers/variable_column_finder.rb, line 30 def find_variable_column_boundaries # Now given both of these, we can eliminate some columns on the left and right variables = left_to_right_index.zip(right_to_left_index).map do |pair| pair == [false, false] end start_column = variables.find_index(true) end_column = variables.reverse.find_index(true) @start_column = start_column || 0 @end_column = (end_column || 1) * -1 end
Private Instance Methods
left_to_right_index()
click to toggle source
# File lib/comma_splice/helpers/variable_column_finder.rb, line 45 def left_to_right_index left_to_right_index = [] @header.split(',').size.times do |time| left_to_right_index.push(@values.map do |value_line| value_line.split(',')[time].to_s.size end.uniq.size == 1) end left_to_right_index end
right_to_left_index()
click to toggle source
# File lib/comma_splice/helpers/variable_column_finder.rb, line 56 def right_to_left_index right_to_left_index = [] @header.split(',').size.times do |time| right_to_left_index.unshift(@values.map do |value_line| value_line.split(',')[-time].to_s.size end.uniq.size == 1) end right_to_left_index end