Class: Hoverboard::Assets::Image
- Inherits:
-
Object
- Object
- Hoverboard::Assets::Image
- Defined in:
- lib/hoverboard/assets/image.rb
Instance Method Summary collapse
- #content_type ⇒ Object
-
#initialize(path) ⇒ Image
constructor
A new instance of Image.
- #to_s ⇒ Object
Constructor Details
#initialize(path) ⇒ Image
Returns a new instance of Image.
4 5 6 |
# File 'lib/hoverboard/assets/image.rb', line 4 def initialize(path) @path = Pathname(path) end |
Instance Method Details
#content_type ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/hoverboard/assets/image.rb', line 12 def content_type case @path.to_s[/\.([^\.]+)$/,1] when 'png' 'image/png' when 'gif' 'image/gif' end end |
#to_s ⇒ Object
8 9 10 |
# File 'lib/hoverboard/assets/image.rb', line 8 def to_s "data:#{content_type};base64," + ([@path.read].pack("m").gsub("\n",'')) end |