Class: Net::HTTPResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/simple/http/expires_in.rb,
lib/simple/http/result.rb

Instance Method Summary collapse

Instance Method Details

#expires_inObject

returns expiration information, in seconds from now.



26
27
28
29
30
31
32
33
# File 'lib/simple/http/expires_in.rb', line 26

def expires_in
  expires_in = max_age
  if !expires_in && expires = header["Expires"]
    expires_in = Time.parse(expires) - Time.now
  end

  return expires_in if expires_in && expires_in > 0
end

#resultObject

evaluate and potentially parse response



11
12
13
14
15
16
17
18
# File 'lib/simple/http/result.rb', line 11

def result
  case response.content_type
  when "application/json"
    JSON.parse(body) unless body.empty?
  else
    body_string
  end
end