Class: Slackr::FileUploader
- Inherits:
-
Object
- Object
- Slackr::FileUploader
- Defined in:
- lib/slackr/file_uploader.rb
Instance Attribute Summary collapse
-
#channels ⇒ Object
readonly
Returns the value of attribute channels.
-
#comment ⇒ Object
readonly
Returns the value of attribute comment.
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#filepath ⇒ Object
readonly
Returns the value of attribute filepath.
-
#filetype ⇒ Object
readonly
Returns the value of attribute filetype.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(connection, filepath, options = {}) ⇒ FileUploader
constructor
A new instance of FileUploader.
- #upload ⇒ Object
Constructor Details
#initialize(connection, filepath, options = {}) ⇒ FileUploader
Returns a new instance of FileUploader.
12 13 14 15 16 17 18 19 20 |
# File 'lib/slackr/file_uploader.rb', line 12 def initialize(connection, filepath, ={}) @connection = connection @filepath = filepath @channels = ['channels'] @filetype = ['filetype'] @filename = ['filename'] @title = ['title'] @comment = ['initial_comment'] end |
Instance Attribute Details
#channels ⇒ Object (readonly)
Returns the value of attribute channels.
10 11 12 |
# File 'lib/slackr/file_uploader.rb', line 10 def channels @channels end |
#comment ⇒ Object (readonly)
Returns the value of attribute comment.
10 11 12 |
# File 'lib/slackr/file_uploader.rb', line 10 def comment @comment end |
#connection ⇒ Object
Returns the value of attribute connection.
9 10 11 |
# File 'lib/slackr/file_uploader.rb', line 9 def connection @connection end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
10 11 12 |
# File 'lib/slackr/file_uploader.rb', line 10 def filename @filename end |
#filepath ⇒ Object (readonly)
Returns the value of attribute filepath.
10 11 12 |
# File 'lib/slackr/file_uploader.rb', line 10 def filepath @filepath end |
#filetype ⇒ Object (readonly)
Returns the value of attribute filetype.
10 11 12 |
# File 'lib/slackr/file_uploader.rb', line 10 def filetype @filetype end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
10 11 12 |
# File 'lib/slackr/file_uploader.rb', line 10 def title @title end |
Instance Method Details
#upload ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/slackr/file_uploader.rb', line 22 def upload response = connection.http_request(multipart) if response.code != "200" raise Slackr::ServiceError, "Slack.com - #{response.code} - #{response.body}" end true end |