Class: CurlAgent::IO
- Inherits:
-
StringIO
- Object
- StringIO
- CurlAgent::IO
- Defined in:
- lib/curl_agent.rb
Instance Attribute Summary collapse
-
#base_uri ⇒ Object
returns a URI which is base of relative URIs in the data.
-
#status ⇒ Object
returns an Array which consists status code and message.
Instance Method Summary collapse
-
#initialize(body_str, header_str) ⇒ IO
constructor
A new instance of IO.
-
#meta ⇒ Object
returns a Hash which represents header fields.
Constructor Details
#initialize(body_str, header_str) ⇒ IO
Returns a new instance of IO.
107 108 109 110 |
# File 'lib/curl_agent.rb', line 107 def initialize(body_str, header_str) super(body_str) @header_str = header_str end |
Instance Attribute Details
#base_uri ⇒ Object
returns a URI which is base of relative URIs in the data. It may differ from the URI supplied by a user because redirection.
105 106 107 |
# File 'lib/curl_agent.rb', line 105 def base_uri @base_uri end |
#status ⇒ Object
returns an Array which consists status code and message.
101 102 103 |
# File 'lib/curl_agent.rb', line 101 def status @status end |
Instance Method Details
#meta ⇒ Object
returns a Hash which represents header fields. The Hash keys are downcased for canonicalization.
114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/curl_agent.rb', line 114 def @meta ||= begin arr = @header_str.split(/\r?\n/) arr.shift arr.inject({}) do |hash, hdr| key, val = hdr.split(/:\s+/, 2) hash[key.downcase] = val hash end end end |