class Thron::Entity::Image
Public Class Methods
new(hash = {})
click to toggle source
Calls superclass method
Thron::Entity::Base::new
# File lib/thron/entity/image.rb, line 4 def initialize(hash = {}) super @path = hash.delete(:path) if valid_path? fetch_mime_type fetch_buffer end end
Private Instance Methods
fetch_buffer()
click to toggle source
# File lib/thron/entity/image.rb, line 24 def fetch_buffer @table[:buffer] ||= File.binread(@path).unpack('c*') new_ostruct_member(:buffer) end
fetch_mime_type()
click to toggle source
# File lib/thron/entity/image.rb, line 19 def fetch_mime_type @table[:mime_type] ||= `file -b --mime-type #{@path}`.to_s.chomp new_ostruct_member(:mime_type) end
valid_path?()
click to toggle source
# File lib/thron/entity/image.rb, line 15 def valid_path? File.readable?(@path.to_s) end