Not sure which is more explicit between ranges and slices...
This commit is contained in:
parent
18808b88c3
commit
57d253c52b
@ -21,9 +21,9 @@ def main
|
|||||||
sock.close
|
sock.close
|
||||||
|
|
||||||
puts "raw response --> #{response.inspect}"
|
puts "raw response --> #{response.inspect}"
|
||||||
code = response[0..30].to_s.strip
|
code = response[0,31].to_s.strip
|
||||||
num = response[31..42].to_s.strip
|
num = response[31,12].to_s.strip
|
||||||
raw_timestamp = response[49..62].to_s.strip
|
raw_timestamp = response[49,14].to_s.strip
|
||||||
timestamp = DateTime.strptime(raw_timestamp, DATEFMT)
|
timestamp = DateTime.strptime(raw_timestamp, DATEFMT)
|
||||||
|
|
||||||
puts "code: '#{code}'"
|
puts "code: '#{code}'"
|
||||||
|
@ -18,12 +18,12 @@ module LineProtocolServer
|
|||||||
end
|
end
|
||||||
|
|
||||||
def receive_data(request)
|
def receive_data(request)
|
||||||
code = request[0..30].to_s.strip
|
code = request[0,31].to_s.strip
|
||||||
num = request[31..42].to_s.strip
|
num = request[31,12].to_s.strip
|
||||||
len = request[43..48].to_s.strip
|
len = request[43,6].to_s.strip
|
||||||
puts "raw date --> '#{request[49..62]}'"
|
puts "raw date --> '#{request[49,14]}'"
|
||||||
timestamp = DateTime.strptime(request[49..62].strip, DATEFMT)
|
timestamp = DateTime.strptime(request[49,14].strip, DATEFMT)
|
||||||
msg = request[63..(63 + len.to_i)].strip
|
msg = request[63,len.to_i+1].strip
|
||||||
|
|
||||||
puts "code: '#{code}'"
|
puts "code: '#{code}'"
|
||||||
puts "num: '#{num}'"
|
puts "num: '#{num}'"
|
||||||
|
Loading…
Reference in New Issue
Block a user