I need to replace all minutes with hours in a file.
Assume a raw file like this:
120m
90m
Should change to:
2h
1.5h
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you can live with it printing “2.0” instead of “2”, you can just do:
If you need it to print it without “.0”, you need to check whether the number is evenly divisible by 60 and if so return
$1.to_i / 60instead of$1.to_f / 60.0.Alternatively you could call
to_son the float and remove.0if the string ends with “.0”