Class: InternetHakai::ResponseObject

Inherits:
Object
  • Object
show all
Defined in:
lib/internethakai/response.rb

Overview

http response

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeResponseObject

Returns a new instance of ResponseObject.



13
14
15
16
17
18
19
20
21
# File 'lib/internethakai/response.rb', line 13

def initialize
    @header = nil
    @status = 0
    @time = 0
    @content_type = ''
    @location = nil
    @body = ''
    @cookie = nil
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



22
23
24
# File 'lib/internethakai/response.rb', line 22

def body
  @body
end

#content_typeObject

Returns the value of attribute content_type.



22
23
24
# File 'lib/internethakai/response.rb', line 22

def content_type
  @content_type
end

Returns the value of attribute cookie.



22
23
24
# File 'lib/internethakai/response.rb', line 22

def cookie
  @cookie
end

#headerObject

Returns the value of attribute header.



22
23
24
# File 'lib/internethakai/response.rb', line 22

def header
  @header
end

#locationObject

Returns the value of attribute location.



22
23
24
# File 'lib/internethakai/response.rb', line 22

def location
  @location
end

#statusObject

Returns the value of attribute status.



22
23
24
# File 'lib/internethakai/response.rb', line 22

def status
  @status
end

#timeObject

Returns the value of attribute time.



22
23
24
# File 'lib/internethakai/response.rb', line 22

def time
  @time
end

Class Method Details

.create_from_nethttp(obj) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/internethakai/response.rb', line 4

def self::create_from_nethttp obj
    r = self::new
    r.body = obj.body.to_s
    r.status = obj.code.to_i
    r.content_type = obj['content-type']
    r.location = obj['location'] if obj['location']
    r.cookie = obj['set-cookie']
    return r
end