Class: Rubtella::HTTPData::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/rubtella/http_data.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status = "", headers = nil, data = "") ⇒ Builder



6
7
8
9
10
# File 'lib/rubtella/http_data.rb', line 6

def initialize status = "", headers = nil, data = ""
  @status = String.new status
  @headers = headers
  @data = String.new data
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



4
5
6
# File 'lib/rubtella/http_data.rb', line 4

def data
  @data
end

#headersObject

Returns the value of attribute headers.



4
5
6
# File 'lib/rubtella/http_data.rb', line 4

def headers
  @headers
end

#statusObject

Returns the value of attribute status.



4
5
6
# File 'lib/rubtella/http_data.rb', line 4

def status
  @status
end

Instance Method Details

#buildObject



12
13
14
15
16
17
18
19
20
# File 'lib/rubtella/http_data.rb', line 12

def build
  @http_data = Array.new
  @http_data << @status
  @http_data << "\r\n"
  @headers.each {|k,v|  @http_data << "#{k}: #{v}\r\n"}
  @http_data << "\r\n"
  @http_data << @data
  @http_data.to_s
end