Skip to content

Instantly share code, notes, and snippets.

@bricker
Created March 4, 2014 03:54
Show Gist options
  • Save bricker/9340005 to your computer and use it in GitHub Desktop.
Save bricker/9340005 to your computer and use it in GitHub Desktop.
hsh = {}
ary = ['02:40', '04:20']
first, last = [ary.first.split(":").map(&:to_i), ary.last.split(":").map(&:to_i)]
hsh = {
first[0] => (60 - first[1])*60,
last[0] => (60-last[1])*60
}
((first[0]+1)...(last[0])).each { |n| hsh[n] = 3600 }
puts hsh #=> {2=>1200, 3=>3600, 4=>2400}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment