Sha256: 76ea0d1b1073e43b8c477e703ce9e612b3cd415efa0ee76f1257af7823bc0a6f

Contents?: true

Size: 603 Bytes

Versions: 1

Compression:

Stored size: 603 Bytes

Contents

# frozen_string_literal: true

module Consolidate
  class Image
    attr_reader :name, :width, :height

    def initialize name:, width:, height:, path: nil, url: nil, contents: nil
      @name = name
      @width = width
      @height = height
      @path = path
      @url = url
      @contents = contents
    end

    def to_s = name

    def contents = @contents ||= contents_from_path || contents_from_url

    private def contents_from_path = @path.nil? ? nil : File.read(@path)

    private def contents_from_url = @url.nil? ? nil : URI.open(@url).read # standard:disable Security/Open
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
standard-procedure-consolidate-0.3.9 lib/consolidate/image.rb