Class: Webspicy::Web::Specification::FileUpload

Inherits:
Object
  • Object
show all
Defined in:
lib/webspicy/web/specification/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.



6
7
8
9
10
# File 'lib/webspicy/web/specification/file_upload.rb', line 6

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.



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

def content_type
  @content_type
end

#param_nameObject (readonly)

Returns the value of attribute param_name.



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

def param_name
  @param_name
end

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end

Class Method Details

.info(raw) ⇒ Object



14
15
16
# File 'lib/webspicy/web/specification/file_upload.rb', line 14

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

Instance Method Details

#locate(specification) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/webspicy/web/specification/file_upload.rb', line 18

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

#to_infoObject



26
27
28
29
30
# File 'lib/webspicy/web/specification/file_upload.rb', line 26

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

#to_sObject Also known as: inspect



32
33
34
# File 'lib/webspicy/web/specification/file_upload.rb', line 32

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