Sha256: 94ee459265b5e01c2889dd1d2614e14dec69e63812ecc9699b0876df06f4a3e7
Contents?: true
Size: 743 Bytes
Versions: 2
Compression:
Stored size: 743 Bytes
Contents
# frozen_string_literal: true module Consolidate class Image attr_reader :name, :width, :height, :aspect_ratio, :dpi def initialize name:, width:, height:, path: nil, url: nil, contents: nil @name = name @width = width @height = height @path = path @url = url @contents = contents @aspect_ratio = width.to_f / height.to_f # TODO: Read this from the contents @dpi = {x: 72, y: 72} 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
standard-procedure-consolidate-0.4.1 | lib/consolidate/image.rb |
standard-procedure-consolidate-0.4.0 | lib/consolidate/image.rb |