From 5390c1adeac5918d4529580776870eb1e729a30c Mon Sep 17 00:00:00 2001 From: Carlos Goce Date: Fri, 23 Jan 2015 00:17:50 +0100 Subject: Refactor calendar to hash --- lib/carlosgoce/calendar.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/carlosgoce/calendar.rb b/lib/carlosgoce/calendar.rb index ea5bd6a..46b3bee 100644 --- a/lib/carlosgoce/calendar.rb +++ b/lib/carlosgoce/calendar.rb @@ -11,14 +11,14 @@ module CarlosGoce end def to_h - h = {} - (1..12).each do |month| - month_name = I18n.t('date.month_names')[month].downcase - month_days =(1...Time.days_in_month(month, @year)).to_a.each_slice(7).to_a - h[month_name] = month_days - end + Hash.new.tap {|bar| + (1..12).each do |month| + month_name = I18n.t('date.month_names')[month].downcase + month_days =(1...Time.days_in_month(month, @year)).to_a.each_slice(7).to_a - h + bar[month_name] = month_days + end + } end end end \ No newline at end of file -- cgit v1.2.3