Class: Gluttonberg::GbFile
- Inherits:
-
File
- Object
- File
- Gluttonberg::GbFile
- Defined in:
- lib/gluttonberg/gb_file.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 Method Summary collapse
Instance Attribute Details
#content_type ⇒ Object
Returns the value of attribute content_type.
8 9 10 |
# File 'lib/gluttonberg/gb_file.rb', line 8 def content_type @content_type end |
#original_filename ⇒ Object
Returns the value of attribute original_filename.
8 9 10 |
# File 'lib/gluttonberg/gb_file.rb', line 8 def original_filename @original_filename end |
#size ⇒ Object
Returns the value of attribute size.
8 9 10 |
# File 'lib/gluttonberg/gb_file.rb', line 8 def size @size end |
Class Method Details
.find_content_type(filename) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/gluttonberg/gb_file.rb', line 21 def self.find_content_type(filename) begin MIME::Types.type_for(filename).first.content_type rescue "" end end |
.init(filename) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/gluttonberg/gb_file.rb', line 10 def self.init(filename) file = self.new(filename) file.original_filename = filename file.content_type = find_content_type(filename) file.size = File.size(filename) file end |
Instance Method Details
#tempfile ⇒ Object
18 19 20 |
# File 'lib/gluttonberg/gb_file.rb', line 18 def tempfile self end |