From d0955e02d6d4c08dfb67e57cda53a12d8c2b26f5 Mon Sep 17 00:00:00 2001 From: Syed Humza Shah Date: Tue, 1 Dec 2015 21:06:37 +0000 Subject: [PATCH] reused value of Time.now in a method `Time.now` was being used to fetch the current time, twice in the same line. This commit stores the time value in a variable and reuses it instead of generating/fetching it for the second time. Additionally, a guard clause in the same method is substituted by an `if/else/end` block for clarity. --- lib/age_words.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/age_words.rb b/lib/age_words.rb index 7fa21c5f4e5..92587ec30f4 100644 --- a/lib/age_words.rb +++ b/lib/age_words.rb @@ -1,8 +1,12 @@ module AgeWords def self.age_words(secs) - return "—" if secs.blank? - return FreedomPatches::Rails4.distance_of_time_in_words(Time.now, Time.now + secs) + if secs.blank? + "—" + else + now = Time.now + FreedomPatches::Rails4.distance_of_time_in_words(now, now + secs) + end end end