Class: Iconoclasm::Headers
- Inherits:
-
Object
- Object
- Iconoclasm::Headers
- Defined in:
- lib/iconoclasm/headers.rb
Constant Summary collapse
- REGEXP =
/^\s*HTTP\/(\d\.\d)\s*(\d{3})\s*(.*)\s*$/i
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #[](header) ⇒ Object
- #content_length ⇒ Object (also: #length)
- #content_type ⇒ Object (also: #type)
-
#initialize(string) ⇒ Headers
constructor
A new instance of Headers.
- #location ⇒ Object
Constructor Details
#initialize(string) ⇒ Headers
Returns a new instance of Headers.
7 8 9 10 11 12 |
# File 'lib/iconoclasm/headers.rb', line 7 def initialize(string) header_string = string.dup http_response = header_string.slice!(REGEXP) @version, @code, @message = parse_http_response(http_response) @header_hash = parse_header_string(header_string.strip) end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
5 6 7 |
# File 'lib/iconoclasm/headers.rb', line 5 def code @code end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
5 6 7 |
# File 'lib/iconoclasm/headers.rb', line 5 def @message end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
5 6 7 |
# File 'lib/iconoclasm/headers.rb', line 5 def version @version end |
Instance Method Details
#[](header) ⇒ Object
14 15 16 |
# File 'lib/iconoclasm/headers.rb', line 14 def [](header) @header_hash[convert_header_key(header.to_s)] end |
#content_length ⇒ Object Also known as: length
23 24 25 |
# File 'lib/iconoclasm/headers.rb', line 23 def content_length @content_length ||= self['content_length'] end |
#content_type ⇒ Object Also known as: type
18 19 20 |
# File 'lib/iconoclasm/headers.rb', line 18 def content_type @content_type ||= self['content_type'] end |
#location ⇒ Object
28 29 30 |
# File 'lib/iconoclasm/headers.rb', line 28 def location @location ||= self['location'] end |