class RemoveBg::Result
Provides convenience methods to save the processed image, read the image data, and access metadata such as the image height/width and credits charged.
Attributes
download[R]
metadata[R]
@return [RemoveBg::ResultMetadata]
rate_limit[R]
@return [RemoveBg::RateLimitInfo]
Public Class Methods
new(download:, metadata:, rate_limit:)
click to toggle source
# File lib/remove_bg/result.rb, line 22 def initialize(download:, metadata:, rate_limit:) @download = download @metadata = metadata @rate_limit = rate_limit end
Public Instance Methods
data()
click to toggle source
Returns the binary data of the processed image @return [String]
# File lib/remove_bg/result.rb, line 44 def data image_file.rewind image_file.read end
save(file_path, overwrite: false)
click to toggle source
Saves the processed image to the path specified @param file_path [string] @param overwrite [boolean] Overwrite any existing file at the specified path @return [nil]
# File lib/remove_bg/result.rb, line 33 def save(file_path, overwrite: false) if File.exist?(file_path) && !overwrite raise FileOverwriteError.new(file_path) end FileUtils.cp(image_file, file_path) end
Private Instance Methods
image_file()
click to toggle source
# File lib/remove_bg/result.rb, line 53 def image_file download end