@@ -27,51 +27,48 @@ def binwrite(name, string, offset = nil)
27
27
end
28
28
end
29
29
30
- # @!visibility private
31
- EMPTY_HASH = { } . freeze
32
-
33
30
# @!visibility private
34
31
alias_method :orig_foreach , :foreach
35
32
36
33
# @!visibility private
37
- def foreach ( name , sep = $/, limit = nil , getline_args = EMPTY_HASH , &block )
34
+ def foreach ( name , sep = $/, limit = nil , ** kwargs , &block )
38
35
if sep . is_a? ( Integer )
39
36
sep = $/
40
37
limit = sep
41
38
end
42
39
File . open ( name , 'r' ) do |f |
43
- f . each_line ( sep , limit , chomp : getline_args [ :chomp ] , &block )
40
+ f . each_line ( sep , limit , chomp : kwargs [ :chomp ] , &block )
44
41
end
45
42
end
46
43
47
44
# @!visibility private
48
45
alias_method :orig_read , :read
49
46
50
47
# @!visibility private
51
- def read ( name , length = nil , offset = nil , opt = EMPTY_HASH )
48
+ def read ( name , length = nil , offset = nil , ** kwargs )
52
49
if length . is_a? ( Hash )
53
- opt = length
50
+ kwargs = length
54
51
length = nil
55
52
end
56
- File . open ( name , opt [ :mode ] || 'r' ) do |f |
53
+ File . open ( name , kwargs [ :mode ] || 'r' ) do |f |
57
54
f . seek ( offset ) if offset
58
55
length ? f . read ( length ) : f . read
59
56
end
60
57
end
61
58
62
59
alias_method :orig_readlines , :readlines
63
- def readlines ( name , sep = $/, limit = nil , getline_args = EMPTY_HASH )
60
+ def readlines ( name , sep = $/, limit = nil , ** kwargs )
64
61
File . open ( name , 'r' ) do |f |
65
- f . readlines ( sep , **getline_args )
62
+ f . readlines ( sep , **kwargs )
66
63
end
67
64
end
68
65
69
66
# @!visibility private
70
67
alias_method :orig_write , :write
71
68
72
69
# @!visibility private
73
- def write ( name , string , offset = nil , opt = EMPTY_HASH )
74
- File . open ( name , opt [ :mode ] || 'w' ) do |f |
70
+ def write ( name , string , offset = nil , ** kwargs )
71
+ File . open ( name , kwargs [ :mode ] || 'w' ) do |f |
75
72
f . seek ( offset ) if offset
76
73
f . write ( string )
77
74
end
0 commit comments