Class: Praxis::MultipartPart

Inherits:
Object
  • Object
show all
Defined in:
lib/praxis/multipart/part.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body, headers = {}, filename: nil) ⇒ MultipartPart

Returns a new instance of MultipartPart.



8
9
10
11
12
# File 'lib/praxis/multipart/part.rb', line 8

def initialize(body, headers={}, filename: nil)
  @body = body
  @headers = headers
  @filename = filename
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



4
5
6
# File 'lib/praxis/multipart/part.rb', line 4

def body
  @body
end

#filenameObject

Returns the value of attribute filename.



6
7
8
# File 'lib/praxis/multipart/part.rb', line 6

def filename
  @filename
end

#headersObject

Returns the value of attribute headers.



5
6
7
# File 'lib/praxis/multipart/part.rb', line 5

def headers
  @headers
end

Instance Method Details

#encode!Object



18
19
20
21
22
23
# File 'lib/praxis/multipart/part.rb', line 18

def encode!
  case @body
  when Hash, Array
    @body = JSON.pretty_generate(@body)
  end
end

#statusObject



14
15
16
# File 'lib/praxis/multipart/part.rb', line 14

def status
  @headers['Status'].to_i
end