Skip to content

Commit 27b0acc

Browse files
committed
Minor, extracted method to improve readability
1 parent 3f9d2fa commit 27b0acc

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Diff for: lib/filewatch/read_mode/handlers/read_file.rb

+10-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,19 @@
22

33
module FileWatch module ReadMode module Handlers
44
class ReadFile < Base
5+
6+
# seek file to which ever is furthest: either current bytes read or sincedb position
7+
private
8+
def seek_to_furthest_position(watched_file)
9+
previous_pos = sincedb_collection.find(watched_file).position
10+
watched_file.file_seek([watched_file.bytes_read, previous_pos].max)
11+
end
12+
13+
public
514
def handle_specifically(watched_file)
615
if open_file(watched_file)
716
add_or_update_sincedb_collection(watched_file) unless sincedb_collection.member?(watched_file.sincedb_key)
8-
previous_pos = sincedb_collection.find(watched_file).position
9-
watched_file.file_seek([watched_file.bytes_read, previous_pos].max)
17+
seek_to_furthest_position(watched_file)
1018
loop do
1119
break if quit?
1220
loop_control = watched_file.loop_control_adjusted_for_stat_size

0 commit comments

Comments
 (0)