Skip to content

Commit

Permalink
Fix ruby 3 warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
mylesboone committed Mar 18, 2022
1 parent 32bbd3f commit 8fa69df
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
7 changes: 2 additions & 5 deletions lib/dbf/column.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,11 @@ def encode(value, strip_output = false) # :nodoc:
end

def encoding_args # :nodoc:
@encoding_args ||= [
Encoding.default_external,
{undef: :replace, invalid: :replace}
]
@encoding_args ||= { undef: :replace, invalid: :replace }
end

def encode_string(string) # :nodoc:
string.force_encoding(@encoding).encode(*encoding_args)
string.force_encoding(@encoding).encode(Encoding.default_external, **encoding_args)
end

def type_cast_class # :nodoc:
Expand Down
10 changes: 3 additions & 7 deletions lib/dbf/column_type.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
module DBF
module ColumnType
class Base
ENCODING_ARGS = [
Encoding.default_external,
{undef: :replace, invalid: :replace}
].freeze
ENCODING_ARGS = { undef: :replace, invalid: :replace }.freeze

attr_reader :decimal, :encoding

Expand Down Expand Up @@ -78,7 +75,7 @@ def type_cast(value)
class Memo < Base
def type_cast(value)
if encoding && !value.nil?
value.force_encoding(@encoding).encode(*ENCODING_ARGS)
value.force_encoding(@encoding).encode(Encoding.default_external, **ENCODING_ARGS)
else
value
end
Expand All @@ -94,9 +91,8 @@ def type_cast(value)
class String < Base
def type_cast(value)
value = value.strip
@encoding ? value.force_encoding(@encoding).encode(*ENCODING_ARGS) : value
@encoding ? value.force_encoding(@encoding).encode(Encoding.default_external, **ENCODING_ARGS) : value
end
end

end
end

0 comments on commit 8fa69df

Please sign in to comment.