Cell Phone Minute Calculation

Ruby comes with a wonderful method that can be used to calculate your cell phone usage by the minutes. Since every cell providers round to next minute, this little line here is all you need to calculate the billable minutes if the system gives you your usage in seconds.

def usage_in_minutes(usage_in_seconds)
usage_in_seconds.to_f./(60).ceil
end

The key here is “ceil” method. Take a look in the Ruby documentation.

Comments

Leave a Reply

You must be logged in to post a comment.