Class: Rhaiker::MultipartBuilder::MultipartData

Inherits:
Object
  • Object
show all
Defined in:
lib/rhaiker/multipart_builder.rb

Direct Known Subclasses

MultipartFileData

Constant Summary collapse

EOL =
"\r\n"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, field_name) ⇒ MultipartData

Returns a new instance of MultipartData.



65
66
67
68
# File 'lib/rhaiker/multipart_builder.rb', line 65

def initialize(value, field_name)
  @value = value
  @field_name = field_name
end

Instance Attribute Details

#field_nameObject

Returns the value of attribute field_name.



63
64
65
# File 'lib/rhaiker/multipart_builder.rb', line 63

def field_name
  @field_name
end

#valueObject

Returns the value of attribute value.



63
64
65
# File 'lib/rhaiker/multipart_builder.rb', line 63

def value
  @value
end

Instance Method Details

#to_sObject



70
71
72
73
74
75
76
# File 'lib/rhaiker/multipart_builder.rb', line 70

def to_s
  body = ''
  body << "Content-Disposition: form-data; name=\"#{@field_name.to_s}\"" << EOL
  body << EOL
  body << @value.to_s << EOL
  return body
end