| 1 | From 8e6f5934541833f15664398f90331f3724e40933 Mon Sep 17 00:00:00 2001
|
| 2 | From: Mamoru TASAKA <[email protected]>
|
| 3 | Date: Tue, 15 Nov 2022 23:22:20 +0900
|
| 4 | Subject: [PATCH] ruby3_2 fix: check if object responds to regex_match op
|
| 5 |
|
| 6 | Object#=~ is already deprecated since ruby2.6 and will be
|
| 7 | removed from ruby3.2. As the result, Array no longer
|
| 8 | respond to =~ from ruby3.2, for example.
|
| 9 |
|
| 10 | Check if the target object really respond to =~ .
|
| 11 |
|
| 12 | Closes #168
|
| 13 | ---
|
| 14 | lib/chunky_png/vector.rb | 2 +-
|
| 15 | 1 file changed, 1 insertion(+), 1 deletion(-)
|
| 16 |
|
| 17 | diff --git a/lib/chunky_png/vector.rb b/lib/chunky_png/vector.rb
|
| 18 | index 4ef965f..034104c 100644
|
| 19 | |
| 20 | |
| 21 | @@ -166,7 +166,7 @@ def dimension
|
| 22 | # @return [Array<ChunkyPNG::Point>] The list of points interpreted from the input array.
|
| 23 | def self.multiple_from_array(source)
|
| 24 | return [] if source.empty?
|
| 25 | - if source.first.is_a?(Numeric) || source.first =~ /^\d+$/
|
| 26 | + if source.first.is_a?(Numeric) || ( source.first.respond_to?(:=~) && source.first =~ /^\d+$/ )
|
| 27 | raise ArgumentError, "The points array is expected to have an even number of items!" if source.length % 2 != 0
|
| 28 |
|
| 29 | points = []
|