SDK oficial para Ruby
Gema oficial de SmallPict para Ruby on Rails, ActiveStorage y Sinatra.
La gema oficial de Ruby se integra de forma transparente con Ruby on Rails, ActiveStorage y aplicaciones Sinatra.
Instalación
Shell
gem install smallpict# o en tu Gemfilegem 'smallpict', '~> 1.2'Ejemplo completo de uso
Ruby
require 'smallpict'
client = SmallPict::Client.new( api_key: ENV['SMALLPICT_API_KEY'], secret_key: ENV['SMALLPICT_SECRET_KEY'])
# 1. Optimizar imagen localresult = client.optimize( file: File.read('hero.png'), filename: 'hero.png', format: 'avif', quality: 80)
puts "URL CDN: #{result.url}"puts "Porcentaje de ahorro: #{result.savings_percentage}%"
# 2. Consultar cuotaquota = client.get_quotaputs "Cuota restante: #{quota.remaining} / #{quota.total}"