Class: Auth::TimeHeader
- Inherits:
-
Object
- Object
- Auth::TimeHeader
- Defined in:
- app/services/auth/time_header.rb
Constant Summary collapse
- TIME_HEADER_FORMAT =
/\A(\d{8})T\d{6}Z\Z/.freeze
- TIME_STRPTIME_FORMAT =
'%Y%m%dT%H%M%SZ%Z'
Instance Attribute Summary collapse
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Instance Method Summary collapse
-
#initialize(header) ⇒ TimeHeader
constructor
A new instance of TimeHeader.
Constructor Details
#initialize(header) ⇒ TimeHeader
Returns a new instance of TimeHeader.
10 11 12 13 14 15 16 17 |
# File 'app/services/auth/time_header.rb', line 10 def initialize(header) match = TIME_HEADER_FORMAT.match(header) raise HeaderParseError, 'Unsupported Gladly-Time header format' if match.nil? @timestamp = match[0] @date = match[1] @time = Time.strptime(, TIME_STRPTIME_FORMAT) end |
Instance Attribute Details
#date ⇒ Object (readonly)
Returns the value of attribute date.
8 9 10 |
# File 'app/services/auth/time_header.rb', line 8 def date @date end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
8 9 10 |
# File 'app/services/auth/time_header.rb', line 8 def time @time end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
8 9 10 |
# File 'app/services/auth/time_header.rb', line 8 def @timestamp end |