Sha256: 5c66bc6f4b6c5936b7ed2ae7122470c8165af964211e476f8ea5a037d18a3bec
Contents?: true
Size: 1.05 KB
Versions: 2
Compression:
Stored size: 1.05 KB
Contents
module Montage # Represents a single source file used in a sprite. # class Source attr_reader :name, :path alias_method :to_s, :name # Creates a new Source instance. # # @param [Pathname] path # The path the the source image. # def initialize(path) @path = Pathname.new(path) @name = @path.basename.to_s.chomp(@path.extname.to_s) end def inspect # :nodoc "#<Montage::Source #{@name}>" end # Returns the RMagick image instance representing the source. # # @return [Magick::Image] # def image raise MissingSource, "Couldn't find the source file `#{@path}'" \ unless @path.file? @image ||= Magick::Image.read(@path).first end # Returns a digest which represents the sprite name and file contents. # # @return [String] # def digest raise MissingSource, "Couldn't find the source file `#{@path}'" \ unless @path.file? Digest::SHA256.hexdigest(@name + Digest::SHA256.file(@path).to_s) end end # Source end # Montage
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
montage-0.4.0 | lib/montage/source.rb |
montage-0.3.0 | lib/montage/source.rb |