Class: Blockspring::Response
- Inherits:
-
Object
- Object
- Blockspring::Response
- Defined in:
- lib/blockspring.rb
Instance Method Summary collapse
- #addErrorOutput(title, message = nil) ⇒ Object
- #addFileOutput(name, filepath) ⇒ Object
- #addOutput(name, value = nil) ⇒ Object
- #end ⇒ Object
-
#initialize ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize ⇒ Response
Returns a new instance of Response.
232 233 234 235 236 237 |
# File 'lib/blockspring.rb', line 232 def initialize @result = { :_blockspring_spec => true, :_errors => [] } end |
Instance Method Details
#addErrorOutput(title, message = nil) ⇒ Object
258 259 260 261 262 263 264 265 266 |
# File 'lib/blockspring.rb', line 258 def addErrorOutput(title, = nil) @result[:_errors].push({ title: title, message: } ) return self end |
#addFileOutput(name, filepath) ⇒ Object
244 245 246 247 248 249 250 251 252 253 254 255 256 |
# File 'lib/blockspring.rb', line 244 def addFileOutput(name, filepath) filename = File.basename(filepath) b64_file_contents = Base64.strict_encode64(File.read(filepath)) mime_type_object = MIME::Types.of(filename).last mime_type = mime_type_object ? mime_type_object.content_type : nil @result[name] = { :filename => filename, :"content-type" => mime_type, :data => b64_file_contents } return self end |
#addOutput(name, value = nil) ⇒ Object
239 240 241 242 |
# File 'lib/blockspring.rb', line 239 def addOutput(name, value = nil) @result[name] = value return self end |
#end ⇒ Object
268 269 270 |
# File 'lib/blockspring.rb', line 268 def end puts @result.to_json end |