Class: HttpHeaders
- Inherits:
-
Object
- Object
- HttpHeaders
- Defined in:
- lib/http_headers.rb
Overview
Class HttpHeaders parses a http header_str from Curl::Easy into component parts.
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
Instance Method Summary collapse
-
#initialize(str) ⇒ HttpHeaders
constructor
A new instance of HttpHeaders.
- #method_missing(sym, *args) ⇒ Object
- #response_code ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(str) ⇒ HttpHeaders
Returns a new instance of HttpHeaders.
6 7 8 |
# File 'lib/http_headers.rb', line 6 def initialize(str) @content = str.split(/\\r\\n|\n|\r/) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args) ⇒ Object
18 19 20 |
# File 'lib/http_headers.rb', line 18 def method_missing(sym, *args) detect_multi_value_keys(sym) end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
4 5 6 |
# File 'lib/http_headers.rb', line 4 def content @content end |
Instance Method Details
#response_code ⇒ Object
14 15 16 |
# File 'lib/http_headers.rb', line 14 def response_code @content[0].match(/HTTP\/\d\.\d (\d{3}.*)/)[1] end |
#version ⇒ Object
10 11 12 |
# File 'lib/http_headers.rb', line 10 def version @content[0].match(/HTTP\/\d\.\d/)[0] end |