Class: Whereuat::Assets::Image

Inherits:
Object
  • Object
show all
Defined in:
lib/whereuat/assets/image.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Image

Returns a new instance of Image.



4
5
6
# File 'lib/whereuat/assets/image.rb', line 4

def initialize(path)
  @path = Pathname(path)
end

Instance Method Details

#content_typeObject



12
13
14
15
16
17
18
19
# File 'lib/whereuat/assets/image.rb', line 12

def content_type
  case @path.to_s[/\.([^\.]+)$/,1]
  when 'png'
    'image/png'
  when 'gif'
    'image/gif'
  end
end

#to_sObject



8
9
10
# File 'lib/whereuat/assets/image.rb', line 8

def to_s
  "data:#{content_type};base64," + ([@path.read].pack("m").gsub("\n",''))
end