Skip to content

Commit fb8c0ef

Browse files
committed
code cleanup
Signed-off-by: Steven Hoffman <fustrate@me.com>
1 parent 46b4789 commit fb8c0ef

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

lib/baseballbot/utility.rb

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
class Baseballbot
44
module Utility
5+
SUBTRACT_THREE_HOURS = -> { it - 10_800 }
6+
57
def self.parse_time_zone(name)
68
TZInfo::Timezone.get name
79
rescue TZInfo::InvalidTimezoneIdentifier
@@ -20,18 +22,15 @@ def self.parse_time(utc, in_time_zone:)
2022
end
2123

2224
def self.adjust_time_proc(post_at)
23-
if post_at =~ /\A-?\d{1,2}\z/
24-
->(time) { time - (Regexp.last_match[0].to_i.abs * 3600) }
25-
elsif post_at =~ /(1[012]|0?\d):(\d\d)/i
26-
constant_time(Regexp.last_match)
25+
case post_at
26+
when /\A-\d{1,2}\z/
27+
-> { it + (post_at.to_i * 3600) }
28+
when /(1[012]|0?\d):(\d\d)/i
29+
-> { Time.new(it.year, it.month, it.day, Regexp.last_match[1].to_i, Regexp.last_match[2].to_i, 0) }
2730
else
2831
# Default to 3 hours before game time
29-
->(time) { time - (3 * 3600) }
32+
SUBTRACT_THREE_HOURS
3033
end
3134
end
32-
33-
def self.constant_time(match_data)
34-
-> { Time.new(it.year, it.month, it.day, match_data[1].to_i, (match_data[2] || '00').to_i, 0) }
35-
end
3635
end
3736
end

0 commit comments

Comments
 (0)