Sha256: 5c803ef01b4c959db8417f4c9853f5f621ad1675b5017164baeaf922ed7c5ae4

Contents?: true

Size: 446 Bytes

Versions: 2

Compression:

Stored size: 446 Bytes

Contents

require 'mime/types'

class Pathname
	def original_image(id)
		dirname + id.to_s + basename
	end

	def thumbnail_image(id, thumbnail_class, mime_type)
		dirname + id.to_s + "#{basename(extname)}-#{thumbnail_class}#{mime_extension(mime_type) or extname}"
	end

	private

	def mime_extension(mime_type)
		mime = MIME::Types[mime_type].first or return nil
		'.' + (mime.extensions.select{|e| e.length == 3}.first or mime.extensions.first)
	end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
httpimagestore-0.1.1 lib/httpimagestore/pathname.rb
httpimagestore-0.1.0 lib/httpimagestore/pathname.rb