Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 7th, 2012  |  syntax: None  |  size: 0.66 KB  |  hits: 7  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ruby-1.9.2-p180 :001 > p = Project.find(1)
  2.   Project Load (0.6ms)  SELECT `projects`.* FROM `projects` WHERE `projects`.`id` = 1 LIMIT 1
  3.  => #<Project id: 1, name: "The First One", startDate: "2011-06-01", endDate: "2011-06-26", created_at: "2011-06-25 17:54:48", updated_at: "2011-06-26 12:33:33", pourcentDate: 102>
  4.  
  5. ruby-1.9.2-p180 :002 > timeTotal = p.endDate - p.startDate
  6.  => (25/1)
  7.  
  8. ruby-1.9.2-p180 :004 > timeUsed = DateTime.now - p.startDate
  9.  => (183782028643/7200000000)
  10.  
  11. ruby-1.9.2-p180 :005 > puts ((timeUsed / timeTotal) * 100)
  12. 183782028643/1800000000
  13.  => nil
  14.  
  15. ruby-1.9.2-p180 :006 > puts ((timeUsed / timeTotal) * 100).to_i
  16. 102
  17.  => nil