Tried out Shoes
I got bored tonight and wanted to write a little script to calculate the amount of time left in my propane tank. Instead of just doing it in Ruby (or Numbers, for that matter), I figured I’d play with Shoes a little. Then I got bored, and really just spat it out and am done with it.
Anyways, for those curious or who want to calculate the time left in their propane tank, here’s the code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | PROPANE_GALLON_WEIGHT = 4.23 BTUS_PER_GALLON = 91_690 Shoes.app do stack do para "Let's figure out how much time you have left in your tank." para "Tare weight?" @tare_weight = edit_line para "Weight?" @weight = edit_line para "BTUs per hour?" @btus_per_hour = edit_line button "Calculate!" do propane_weight = @weight.text.to_i - @tare_weight.text.to_i gallons_of_propane = propane_weight / PROPANE_GALLON_WEIGHT btus = gallons_of_propane * BTUS_PER_GALLON hours_remaining = btus / @btus_per_hour.text.to_i alert("Hours remaining: #{hours_remaining}") end end end |