Top Level Namespace

Defined Under Namespace

Modules: DataFiles, Shunkuntype Classes: FinishCheck, MkPlots, MkSummary, PlotData, PlotPersonalData, SpeedCheck, Training

Instance Method Summary collapse

Instance Method Details

#data_merge(file_current, file_server) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/shunkuntype/merge.rb', line 3

def data_merge(file_current, file_server)
  all_data=[]
  i,j=0,0
  while (file_current.length > i) and (file_server.length > j) do
    line_current,line_server = file_current[i], file_server[j]
    break if line_current=="\n" or line_server=="\n"
    time_current=Time.parse(line_current.split(',')[0])
    time_server=Time.parse(line_server.split(',')[0])
    if time_current == time_server then
      all_data << line_current
      i += 1
      j += 1
    elsif time_current < time_server then
      all_data << line_current
      i += 1
    else
      all_data << line_server
      j += 1
    end
  end
  while (file_current.length > i)
    all_data << file_current[i]
    i += 1
  end
  while (file_server.length > j)
    all_data <<  file_server[j]
    j += 1
  end
  all_data.delete("\n")
  return all_data.join
end