# frozen_string_literal: true module Booru # Holds information about a scraper run. # @see Scraper class ScraperResult # Errors occurring during scraper execution. # @return [Array] attr_reader :errors # Type of data found - image, paste, audio # @return [String] attr_reader :type # The source URL. This is usually the URL provided, # after any redirects have been resolved. # @return [String] attr_reader :source_url # The author's name. # @return [String] attr_reader :author_name # An optional description. Should not contain any # HTML, if present. # @return [String] attr_reader :description # The images associated with a scraper run. # @return [Array] attr_reader :images # Tags that should be applied to the image, when scraping from other boorus. # @return [Array] attr_reader :tags # Name of the other booru that this image came from; used for adding import tags later. # @return [String] attr_reader :booru # @return [Array] attr_reader :sha512_hashes def initialize(errors: [], type: nil, source_url: nil, author_name: nil, description: nil, images: [], tags: [], booru: nil, sha512_hashes: []) @errors = errors @type = type @source_url = source_url @author_name = author_name @description = description @images = images @tags = tags @booru = booru @sha512_hashes = sha512_hashes.compact end # Representation of this result, suitable for serialization to JSON. # @return [Hash] def as_json(*) { errors: errors, source_url: source_url, author_name: author_name, description: description, images: images.as_json, tags: tags } end # Default equality test. True if all attributes are equal. # @return [true, false] def ==(other) as_json == other.as_json end end end