Created
          October 7, 2008 09:34 
        
      - 
      
- 
        Save sunny/15263 to your computer and use it in GitHub Desktop. 
  
    
      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
    
  
  
    
  | Shoes.app :title => "Heure de fin", :width => 200, :height => 160, :resizable => false do | |
| background "#FFF".."#DDD" | |
| stack :margin => 10 do | |
| flow { | |
| para "Arrivée à" | |
| @time_start = edit_line(:width => 42, :text => '10h00') { calc } | |
| } | |
| flow { | |
| para "Travailler" | |
| @time_work = edit_line(:width => 42, :text => '08h00') { calc } | |
| } | |
| flow { | |
| para "Pause de" | |
| @time_pause = edit_line(:width => 42, :text => '01h15') { calc } | |
| } | |
| para "Heure de fin : ", @time_end = strong | |
| end | |
| animate { calc; stop } # should have been "start { calc }" but that didn't work out | |
| def calc | |
| # sum the edit box's minutes | |
| total = [@time_work.text, @time_start.text, @time_pause.text].inject(0) do |acc,text| | |
| h, m = *text.split(/[:h]/) | |
| acc + h.to_i*60 + m.to_i | |
| end | |
| @time_end.replace "%02dh%02d" % [total/60, total%60] | |
| end | |
| end | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment