Created
March 8, 2013 22:22
-
-
Save zeroeth/5120395 to your computer and use it in GitHub Desktop.
timestamp to seconds
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def duration_to_seconds(duration) | |
| numbers = duration.split(":").map(&:to_i) | |
| (numbers[0]*60) + numbers[1] | |
| end | |
| total_seconds = duration_to_seconds("12:05") | |
| puts "#{total_seconds} should_equal 725" |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
map{|x| x.to_i} == map(&:to_i)