Class: Mosquito::MockUpload
- Inherits:
-
StringIO
- Object
- StringIO
- Mosquito::MockUpload
- Defined in:
- lib/mosquito.rb
Overview
Constant Summary collapse
- IMAGE_TYPES =
{:jpg => 'image/jpeg', :png => 'image/png', :gif => 'image/gif', :pdf => 'application/pdf' }.stringify_keys
Instance Attribute Summary collapse
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
-
#extension ⇒ Object
readonly
Returns the value of attribute extension.
-
#local_path ⇒ Object
readonly
Returns the value of attribute local_path.
-
#original_filename ⇒ Object
readonly
Returns the value of attribute original_filename.
Instance Method Summary collapse
-
#initialize(filename) ⇒ MockUpload
constructor
A new instance of MockUpload.
- #inspect ⇒ Object
Constructor Details
#initialize(filename) ⇒ MockUpload
Returns a new instance of MockUpload.
337 338 339 340 341 342 343 344 345 346 347 348 |
# File 'lib/mosquito.rb', line 337 def initialize(filename) tempname = "tempfile_#{Time.now.to_i}" @temp = ::Tempfile.new(tempname) @local_path = @temp.path @original_filename = File.basename(filename) @extension = File.extname(@original_filename).gsub(/^\./, '').downcase @content_type = IMAGE_TYPES[@extension] || "application/#{@extension}" size = 100.bytes super("Stub file %s \n%s\n" % [@original_filename, Mosquito::garbage(size)]) end |
Instance Attribute Details
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
333 334 335 |
# File 'lib/mosquito.rb', line 333 def content_type @content_type end |
#extension ⇒ Object (readonly)
Returns the value of attribute extension.
333 334 335 |
# File 'lib/mosquito.rb', line 333 def extension @extension end |
#local_path ⇒ Object (readonly)
Returns the value of attribute local_path.
333 334 335 |
# File 'lib/mosquito.rb', line 333 def local_path @local_path end |
#original_filename ⇒ Object (readonly)
Returns the value of attribute original_filename.
333 334 335 |
# File 'lib/mosquito.rb', line 333 def original_filename @original_filename end |
Instance Method Details
#inspect ⇒ Object
350 351 352 353 |
# File 'lib/mosquito.rb', line 350 def inspect info = " @size='#{length}' @filename='#{original_filename}' @content_type='#{content_type}'>" super[0..-2] + info end |