Class: Protocol::HTTP::Header::Date
- Inherits:
-
String
- Object
- String
- Protocol::HTTP::Header::Date
- Defined in:
- lib/protocol/http/header/date.rb
Overview
The date header represents the date and time at which the message was originated.
This header is typically included in HTTP responses and follows the format defined in RFC 9110.
Class Method Summary collapse
-
.coerce(value) ⇒ Object
Coerces a value into a parsed header object.
-
.parse(value) ⇒ Object
Parses a raw header value.
-
.trailer? ⇒ Boolean
Whether this header is acceptable in HTTP trailers.
Instance Method Summary collapse
-
#<<(value) ⇒ Object
Replaces the current value of the
dateheader. -
#to_time ⇒ Object
Converts the
dateheader value to aTimeobject.
Class Method Details
.coerce(value) ⇒ Object
Coerces a value into a parsed header object.
27 28 29 |
# File 'lib/protocol/http/header/date.rb', line 27 def self.coerce(value) self.new(value.to_s) end |
.parse(value) ⇒ Object
Parses a raw header value.
19 20 21 |
# File 'lib/protocol/http/header/date.rb', line 19 def self.parse(value) self.new(value) end |
.trailer? ⇒ Boolean
Whether this header is acceptable in HTTP trailers. Date headers can safely appear in trailers as they provide metadata about response generation.
48 49 50 |
# File 'lib/protocol/http/header/date.rb', line 48 def self.trailer? true end |
Instance Method Details
#<<(value) ⇒ Object
Replaces the current value of the date header.
34 35 36 |
# File 'lib/protocol/http/header/date.rb', line 34 def << value replace(value) end |
#to_time ⇒ Object
Converts the date header value to a Time object.
41 42 43 |
# File 'lib/protocol/http/header/date.rb', line 41 def to_time ::Time.parse(self) end |