Class: Cocupu::File
- Inherits:
-
Object
- Object
- Cocupu::File
- Defined in:
- lib/cocupu/file.rb
Instance Attribute Summary collapse
-
#conn ⇒ Object
readonly
Returns the value of attribute conn.
-
#file ⇒ Object
Returns the value of attribute file.
-
#file_name ⇒ Object
Returns the value of attribute file_name.
-
#node ⇒ Object
Returns the value of attribute node.
Instance Method Summary collapse
-
#initialize(node, file_name, file) ⇒ File
constructor
A new instance of File.
- #save ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(node, file_name, file) ⇒ File
Returns a new instance of File.
5 6 7 8 9 10 |
# File 'lib/cocupu/file.rb', line 5 def initialize(node, file_name, file) self.node = node self.file_name = file_name self.file = file @conn = Thread.current[:cocupu_connection] end |
Instance Attribute Details
#conn ⇒ Object (readonly)
Returns the value of attribute conn.
4 5 6 |
# File 'lib/cocupu/file.rb', line 4 def conn @conn end |
#file ⇒ Object
Returns the value of attribute file.
3 4 5 |
# File 'lib/cocupu/file.rb', line 3 def file @file end |
#file_name ⇒ Object
Returns the value of attribute file_name.
3 4 5 |
# File 'lib/cocupu/file.rb', line 3 def file_name @file_name end |
#node ⇒ Object
Returns the value of attribute node.
3 4 5 |
# File 'lib/cocupu/file.rb', line 3 def node @node end |
Instance Method Details
#save ⇒ Object
16 17 18 19 |
# File 'lib/cocupu/file.rb', line 16 def save response = conn.post("#{url}.json")#, query: {file_name: file_name, file: file}) raise "Error saving file: #{response.inspect}" unless response.code >= 200 and response.code < 300 end |
#url ⇒ Object
12 13 14 |
# File 'lib/cocupu/file.rb', line 12 def url node.url + "/files" end |