# frozen_string_literal: true module Booru # A single image associated with a scraper run. class ScraperImage # The direct URL of this image. # @return [String] attr_reader :url # @return [String] attr_reader :preview # An indirect URL of this image throuhg camo, suitable for # rendering in-browser. # @return [String] attr_reader :camo_url # Type: text, image, audio # @return [String] attr_reader :type # Creates a new ScraperImage with the specified parameters. def initialize(url:, type:, camo_url: nil, preview: nil) @url = url @type = type @camo_url = camo_url || Camo.image_url(url) @preview = preview end # JSON representation of this image pair. # @return [Hash] def as_json(*) { type: type, url: url, camo_url: camo_url, preview: preview } end def ==(other) as_json == other.as_json end end end