Class: Blockspring::Response
- Inherits:
-
Object
- Object
- Blockspring::Response
- Defined in:
- lib/blockspring.rb
Instance Method Summary collapse
- #addFileOutput(name, filepath) ⇒ Object
- #addOutput(name, value) ⇒ Object
- #end ⇒ Object
-
#initialize ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize ⇒ Response
Returns a new instance of Response.
54 55 56 57 58 59 60 |
# File 'lib/blockspring.rb', line 54 def initialize @result = { data: {}, files: {}, errors: nil } end |
Instance Method Details
#addFileOutput(name, filepath) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/blockspring.rb', line 67 def addFileOutput(name, filepath) filename = File.basename(filepath) b64_file_contents = Base64.encode64(File.read(filepath)) mime_type_object = MIME::Types.of(filename).first mime_type = mime_type_object ? mime_type_object.content_type : nil @result[:files][name] = { filename: filename, mimeType: mime_type, data: b64_file_contents } return self end |
#addOutput(name, value) ⇒ Object
62 63 64 65 |
# File 'lib/blockspring.rb', line 62 def addOutput(name, value) @result[:data][name] = value return self end |
#end ⇒ Object
81 82 83 |
# File 'lib/blockspring.rb', line 81 def end puts @result.to_json end |