Class: Bcli::FileClient
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #file_contents ⇒ Object
- #file_headers ⇒ Object
-
#initialize(file_path = nil, options = {}) ⇒ FileClient
constructor
A new instance of FileClient.
- #upload ⇒ Object
Methods inherited from Client
#delete, #get, #patch, #post, #put
Constructor Details
#initialize(file_path = nil, options = {}) ⇒ FileClient
Returns a new instance of FileClient.
3 4 5 6 7 8 |
# File 'lib/bcli/file_client.rb', line 3 def initialize(file_path = nil, = {}) @file_path = file_path @file = file_contents @config = Bcli::Config.new @options = end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
2 3 4 |
# File 'lib/bcli/file_client.rb', line 2 def config @config end |
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
2 3 4 |
# File 'lib/bcli/file_client.rb', line 2 def content_type @content_type end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
2 3 4 |
# File 'lib/bcli/file_client.rb', line 2 def file @file end |
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
2 3 4 |
# File 'lib/bcli/file_client.rb', line 2 def file_path @file_path end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
2 3 4 |
# File 'lib/bcli/file_client.rb', line 2 def token @token end |
Instance Method Details
#file_contents ⇒ Object
29 30 31 |
# File 'lib/bcli/file_client.rb', line 29 def file_contents File.open(file_path, "r") if file_path end |
#file_headers ⇒ Object
22 23 24 25 26 27 |
# File 'lib/bcli/file_client.rb', line 22 def file_headers { "Content-Type": "multipart/form-data", Authorization: "Bearer #{config.creds[:token]}" } end |