From 179cbaacbee31fcfed15be3da51674f74ef6f0fa Mon Sep 17 00:00:00 2001 From: Alpha Chen Date: Sat, 22 Nov 2014 13:13:31 -0800 Subject: [PATCH] [alfred] Update Forecast workflow --- .../forecast.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.8694C3FC-8218-4B98-BB1F-F1CEC686477C/forecast.rb b/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.8694C3FC-8218-4B98-BB1F-F1CEC686477C/forecast.rb index dd24d3e..77d03c5 100644 --- a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.8694C3FC-8218-4B98-BB1F-F1CEC686477C/forecast.rb +++ b/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.8694C3FC-8218-4B98-BB1F-F1CEC686477C/forecast.rb @@ -78,11 +78,12 @@ items << Item.new( minutely = forecast['minutely'] if minutely - intensity = minutely['data'].map {|m| 1000 * m['precipIntensity'] } - intensity = intensity.select.with_index {|_,i| i % 5 == 0 } + intensity = minutely['data'].map {|m| m['precipIntensity'] } + intensity = intensity.select.with_index {|_,i| i % 4 == 0 } min, max = intensity.minmax + intensity = intensity.map {|i| 1000 * i } - subtitle = ["#{min.round}\" #{Spark.new(intensity)} #{max.round}\""] + subtitle = ["#{min.round(3)}\" #{Spark.new(intensity)} #{max.round(3)}\""] probability = minutely['data'].map {|m| (100 * m['precipProbability']).round } probability = probability.select.with_index {|_,i| i % 5 == 0 } @@ -100,11 +101,12 @@ end hourly = forecast['hourly'] -intensity = hourly['data'].map {|m| 1000 * m['precipIntensity'] } +intensity = hourly['data'].map {|m| m['precipIntensity'] } intensity = intensity.select.with_index {|_,i| i % 4 == 0 } min, max = intensity.minmax +intensity = intensity.map {|i| 1000 * i } -subtitle = ["#{min.round}\" #{Spark.new(intensity)} #{max.round}\""] +subtitle = ["#{min.round(3)}\" #{Spark.new(intensity)} #{max.round(3)}\""] probability = hourly['data'].map {|m| (100 * m['precipProbability']).round } probability = probability.select.with_index {|_,i| i % 4 == 0 }