Class: Gluttonberg::MyFile2
- Inherits:
-
File
- Object
- File
- Gluttonberg::MyFile2
- Defined in:
- app/models/gluttonberg/asset.rb
Overview
i made this class for providing extra methods in file class. I am using it for making assets from zip folder. keep in mind when we upload asset from browser, browser injects three extra attributes (that are given in MyFile class) but we are adding assets from file, i am injecting extra attributes manually. because asset library assumes that file has three extra attributes
Instance Attribute Summary collapse
-
#content_type ⇒ Object
Returns the value of attribute content_type.
-
#original_filename ⇒ Object
Returns the value of attribute original_filename.
-
#size ⇒ Object
Returns the value of attribute size.
Class Method Summary collapse
Instance Attribute Details
#content_type ⇒ Object
Returns the value of attribute content_type.
174 175 176 |
# File 'app/models/gluttonberg/asset.rb', line 174 def content_type @content_type end |
#original_filename ⇒ Object
Returns the value of attribute original_filename.
174 175 176 |
# File 'app/models/gluttonberg/asset.rb', line 174 def original_filename @original_filename end |
#size ⇒ Object
Returns the value of attribute size.
174 175 176 |
# File 'app/models/gluttonberg/asset.rb', line 174 def size @size end |
Class Method Details
.find_content_type(filename) ⇒ Object
184 185 186 187 188 189 190 |
# File 'app/models/gluttonberg/asset.rb', line 184 def self.find_content_type(filename) begin MIME::Types.type_for(filename).first.content_type rescue "" end end |
.init(filename) ⇒ Object
176 177 178 179 180 181 182 |
# File 'app/models/gluttonberg/asset.rb', line 176 def self.init(filename) file = MyFile2.new(Rails.root+"/bulks/" + filename) file.original_filename = filename file.content_type = find_content_type(filename) file.size = File.size(Rails.root+"/bulks/" + filename) file end |