Class: Lookbook::FileDataUriEncoder
- Defined in:
- lib/lookbook/services/urls/file_data_uri_encoder.rb
Instance Attribute Summary collapse
- #path ⇒ Object readonly
Instance Method Summary collapse
- #call ⇒ Object
- #content ⇒ Object
-
#initialize(path, mime_type = nil) ⇒ FileDataUriEncoder
constructor
A new instance of FileDataUriEncoder.
- #mime_type ⇒ Object
Methods inherited from Service
Constructor Details
#initialize(path, mime_type = nil) ⇒ FileDataUriEncoder
Returns a new instance of FileDataUriEncoder.
7 8 9 10 |
# File 'lib/lookbook/services/urls/file_data_uri_encoder.rb', line 7 def initialize(path, mime_type = nil) @path = path @mime_type = mime_type end |
Instance Attribute Details
#path ⇒ Object (readonly)
5 6 7 |
# File 'lib/lookbook/services/urls/file_data_uri_encoder.rb', line 5 def path @path end |
Instance Method Details
#call ⇒ Object
20 21 22 |
# File 'lib/lookbook/services/urls/file_data_uri_encoder.rb', line 20 def call DataUriEncoder.call(content, mime_type) end |
#content ⇒ Object
12 13 14 |
# File 'lib/lookbook/services/urls/file_data_uri_encoder.rb', line 12 def content File.read(path) end |
#mime_type ⇒ Object
16 17 18 |
# File 'lib/lookbook/services/urls/file_data_uri_encoder.rb', line 16 def mime_type @mime_type || Marcel::MimeType.for(Pathname.new(path)) end |