Sha256: 6cc895393e8d90664d969c1a8a43d51b071cede132213228214f697a65dc0c9f
Contents?: true
Size: 608 Bytes
Versions: 1
Compression:
Stored size: 608 Bytes
Contents
module Thron module Entity class Image < Base def initialize(hash = {}) super @path = hash.delete(:path) if valid_path? fetch_mime_type fetch_buffer end end private def valid_path? File.readable?(@path.to_s) end def fetch_mime_type @table[:mime_type] ||= `file -b --mime-type #{@path}`.to_s.chomp new_ostruct_member(:mime_type) end def fetch_buffer @table[:buffer] ||= File.binread(@path).unpack('c*') new_ostruct_member(:buffer) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
thron-0.7.0 | lib/thron/entity/image.rb |