class UDPRest::UHTTPResponse

Attributes

code[RW]
protocol[RW]
text[RW]

Public Class Methods

new(code, options = {}) click to toggle source
# File lib/udp_rest/uhttp.rb, line 67
def initialize(code, options = {})
    self.code = code.to_i
    self.protocol = options[:protocol] || 'UHTTP/1.0'
    self.text = options[:text] || ''
end
parse(s) click to toggle source
# File lib/udp_rest/uhttp.rb, line 73
def self.parse(s)
    data = s.split("\n\n")
    status = data[0].split(' ')
    text = data[1] if data.length > 1
    self.new(status[1], :text => text || '')
end

Public Instance Methods

ok?() click to toggle source
# File lib/udp_rest/uhttp.rb, line 80
def ok?
    code == 200
end
status_line() click to toggle source
# File lib/udp_rest/uhttp.rb, line 89
def status_line
    "#{protocol} #{code} #{status_text}"
end
status_text() click to toggle source
# File lib/udp_rest/uhttp.rb, line 84
def status_text
    return 'OK' if ok?
    return 'FAILED'
end
to_s() click to toggle source
# File lib/udp_rest/uhttp.rb, line 93
def to_s
    "#{status_line}\n\n#{text}"
end