Class: Webspicy::FileUpload

Inherits:
Object
  • Object
show all
Defined in:
lib/webspicy/file_upload.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw) ⇒ FileUpload

Returns a new instance of FileUpload.



4
5
6
7
8
# File 'lib/webspicy/file_upload.rb', line 4

def initialize(raw)
  @path = raw[:path]
  @content_type = raw[:content_type]
  @param_name = raw[:param_name] || "file"
end

Instance Attribute Details

#content_typeObject (readonly)

Returns the value of attribute content_type.



10
11
12
# File 'lib/webspicy/file_upload.rb', line 10

def content_type
  @content_type
end

#param_nameObject (readonly)

Returns the value of attribute param_name.



10
11
12
# File 'lib/webspicy/file_upload.rb', line 10

def param_name
  @param_name
end

#pathObject (readonly)

Returns the value of attribute path.



10
11
12
# File 'lib/webspicy/file_upload.rb', line 10

def path
  @path
end

Class Method Details

.info(raw) ⇒ Object



12
13
14
# File 'lib/webspicy/file_upload.rb', line 12

def self.info(raw)
  new(raw)
end

Instance Method Details

#locate(resource) ⇒ Object



16
17
18
19
20
21
# File 'lib/webspicy/file_upload.rb', line 16

def locate(resource)
  FileUpload.new({
    path: resource.locate(path),
    content_type: content_type
  })
end

#to_infoObject



23
24
25
26
27
# File 'lib/webspicy/file_upload.rb', line 23

def to_info
  { path: path.to_s,
    content_type: content_type,
    param_name: param_name }
end

#to_sObject Also known as: inspect



29
30
31
# File 'lib/webspicy/file_upload.rb', line 29

def to_s
  "FileUpload(#{to_info})"
end