Sha256: 8db9b32cc7c73da5ef7863613b8c7f8b619a89a90472ff0e859c72bac6890fd0
Contents?: true
Size: 760 Bytes
Versions: 10
Compression:
Stored size: 760 Bytes
Contents
#!/usr/bin/env ruby require 'json' require 'optparse' options = {} OptionParser.new do |opts| opts.banner = "Usage: #{$0} [OPTIONS]" opts.on('-k', '--key [NAME]', 'Key in json to look for a timestamp.') do |value| options[:key] = value end end.parse! required_options = [:key] required_options.each do |option| unless options[option] $stderr.puts "Can not run #{option.to_s} was not given." exit 1 end end times = [] distances = [] previous = nil STDIN.each_line do |line| object = JSON.parse(line) times << object[options[:key]] end times.sort do |a, b| a <=> b end.each do |time| if previous distances << time - previous end previous = time end distances.each do |distance| puts "distance #{distance}" end
Version data entries
10 entries across 10 versions & 1 rubygems