Skip to content

Commit

Permalink
ruby3_2 fix: check if object responds to regex_match op
Browse files Browse the repository at this point in the history
Object#=~ is already deprecated since ruby2.6 and will be
removed from ruby3.2. As the result, Array no longer
respond to =~ from ruby3.2, for example.

Check if the target object really respond to =~ .

Closes wvanbergen#168
  • Loading branch information
mtasaka committed Nov 15, 2022
1 parent 7a1faf6 commit 8e6f593
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/chunky_png/vector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def dimension
# @return [Array<ChunkyPNG::Point>] The list of points interpreted from the input array.
def self.multiple_from_array(source)
return [] if source.empty?
if source.first.is_a?(Numeric) || source.first =~ /^\d+$/
if source.first.is_a?(Numeric) || ( source.first.respond_to?(:=~) && source.first =~ /^\d+$/ )
raise ArgumentError, "The points array is expected to have an even number of items!" if source.length % 2 != 0

points = []
Expand Down

0 comments on commit 8e6f593

Please sign in to comment.