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.
108 109 110 111 |
# File 'lib/curl_agent.rb', line 108 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.
106 107 108 |
# File 'lib/curl_agent.rb', line 106 def base_uri @base_uri end |
#status ⇒ Object
returns an Array which consists status code and message.
102 103 104 |
# File 'lib/curl_agent.rb', line 102 def status @status end |
Instance Method Details
#meta ⇒ Object
returns a Hash which represents header fields. The Hash keys are downcased for canonicalization.
115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/curl_agent.rb', line 115 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 |