Class: Smithy::Asset
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Smithy::Asset
- Defined in:
- app/models/smithy/asset.rb
Instance Method Summary collapse
Instance Method Details
#data ⇒ Object
55 56 57 |
# File 'app/models/smithy/asset.rb', line 55 def data file.read end |
#file_type ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/models/smithy/asset.rb', line 13 def file_type case file_content_type when /^image\/svg/ :direct_image when /^image\/?/ :image when /pdf/ :pdf when /msword|wordprocessing/ :word when /excel|spreadsheet/ :excel when /powerpoint|presentation/ :powerpoint when /txt/ :text when /rtf/ :document else :default end end |
#to_liquid ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/models/smithy/asset.rb', line 36 def to_liquid { 'id' => self.id, 'name' => self.name, 'content_type' => self.file_content_type, 'file' => self.file, 'file_name' => self.file_filename, 'file_width' => self.file_width, 'file_height' => self.file_height, 'file_size' => self.file_size, 'remote_url' => self.url, 'url' => self.url } end |
#url ⇒ Object
51 52 53 |
# File 'app/models/smithy/asset.rb', line 51 def url Refile.(self, :file) end |