Skip to content

Commit 7cc7e57

Browse files
committed
Rubocop
1 parent 34c665e commit 7cc7e57

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lib/openai/images.rb

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,20 @@ def open_files(parameters)
2222
params = parameters.dup
2323

2424
if params[:image].is_a?(Array)
25-
# Create indexed image parameters (image[0], image[1], etc.)
26-
params[:image].each_with_index do |img_path, index|
27-
params[:"image[#{index}]"] = File.open(img_path)
28-
end
29-
params.delete(:image)
25+
process_image_array(params)
3026
else
3127
params[:image] = File.open(params[:image])
3228
end
29+
3330
params[:mask] = File.open(params[:mask]) if params[:mask]
3431
params
3532
end
33+
34+
def process_image_array(params)
35+
params[:image].each_with_index do |img_path, index|
36+
params[:"image[#{index}]"] = File.open(img_path)
37+
end
38+
params.delete(:image)
39+
end
3640
end
3741
end

0 commit comments

Comments
 (0)