Class: RubyLLM::Agents::CachedBackgroundRemovalResult

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_llm/agents/results/background_removal_result.rb

Overview

Lightweight result for cached removals

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ CachedBackgroundRemovalResult

Returns a new instance of CachedBackgroundRemovalResult.



245
246
247
248
249
250
251
252
253
254
255
# File 'lib/ruby_llm/agents/results/background_removal_result.rb', line 245

def initialize(data)
  @url = data[:url]
  @data = data[:data]
  @mask_url = data[:mask_url]
  @mask_data = data[:mask_data]
  @mime_type = data[:mime_type]
  @model_id = data[:model_id]
  @output_format = data[:output_format]
  @total_cost = data[:total_cost]
  @cached_at = data[:cached_at]
end

Instance Attribute Details

#cached_atObject (readonly)

Returns the value of attribute cached_at.



242
243
244
# File 'lib/ruby_llm/agents/results/background_removal_result.rb', line 242

def cached_at
  @cached_at
end

#dataObject (readonly)

Returns the value of attribute data.



242
243
244
# File 'lib/ruby_llm/agents/results/background_removal_result.rb', line 242

def data
  @data
end

#mask_dataObject (readonly)

Returns the value of attribute mask_data.



242
243
244
# File 'lib/ruby_llm/agents/results/background_removal_result.rb', line 242

def mask_data
  @mask_data
end

#mask_urlObject (readonly)

Returns the value of attribute mask_url.



242
243
244
# File 'lib/ruby_llm/agents/results/background_removal_result.rb', line 242

def mask_url
  @mask_url
end

#mime_typeObject (readonly)

Returns the value of attribute mime_type.



242
243
244
# File 'lib/ruby_llm/agents/results/background_removal_result.rb', line 242

def mime_type
  @mime_type
end

#model_idObject (readonly)

Returns the value of attribute model_id.



242
243
244
# File 'lib/ruby_llm/agents/results/background_removal_result.rb', line 242

def model_id
  @model_id
end

#output_formatObject (readonly)

Returns the value of attribute output_format.



242
243
244
# File 'lib/ruby_llm/agents/results/background_removal_result.rb', line 242

def output_format
  @output_format
end

#total_costObject (readonly)

Returns the value of attribute total_cost.



242
243
244
# File 'lib/ruby_llm/agents/results/background_removal_result.rb', line 242

def total_cost
  @total_cost
end

#urlObject (readonly)

Returns the value of attribute url.



242
243
244
# File 'lib/ruby_llm/agents/results/background_removal_result.rb', line 242

def url
  @url
end

Instance Method Details

#base64?Boolean

Returns:

  • (Boolean)


277
278
279
# File 'lib/ruby_llm/agents/results/background_removal_result.rb', line 277

def base64?
  !data.nil?
end

#batch?Boolean

Returns:

  • (Boolean)


297
298
299
# File 'lib/ruby_llm/agents/results/background_removal_result.rb', line 297

def batch?
  false
end

#cached?Boolean

Returns:

  • (Boolean)


265
266
267
# File 'lib/ruby_llm/agents/results/background_removal_result.rb', line 265

def cached?
  true
end

#countObject



289
290
291
# File 'lib/ruby_llm/agents/results/background_removal_result.rb', line 289

def count
  success? ? 1 : 0
end

#datasObject



273
274
275
# File 'lib/ruby_llm/agents/results/background_removal_result.rb', line 273

def datas
  success? ? [data].compact : []
end

#error?Boolean

Returns:

  • (Boolean)


261
262
263
# File 'lib/ruby_llm/agents/results/background_removal_result.rb', line 261

def error?
  !success?
end

#has_alpha?Boolean

Returns:

  • (Boolean)


285
286
287
# File 'lib/ruby_llm/agents/results/background_removal_result.rb', line 285

def has_alpha?
  %i[png webp].include?(output_format&.to_sym)
end

#mask?Boolean

Returns:

  • (Boolean)


281
282
283
# File 'lib/ruby_llm/agents/results/background_removal_result.rb', line 281

def mask?
  !mask_url.nil? || !mask_data.nil?
end

#single?Boolean

Returns:

  • (Boolean)


293
294
295
# File 'lib/ruby_llm/agents/results/background_removal_result.rb', line 293

def single?
  true
end

#success?Boolean

Returns:

  • (Boolean)


257
258
259
# File 'lib/ruby_llm/agents/results/background_removal_result.rb', line 257

def success?
  !url.nil? || !data.nil?
end

#urlsObject



269
270
271
# File 'lib/ruby_llm/agents/results/background_removal_result.rb', line 269

def urls
  success? ? [url].compact : []
end