Class: Auth::TimeHeader

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(header) ⇒ TimeHeader

Returns a new instance of TimeHeader.

Raises:



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(utc_timestamp, TIME_STRPTIME_FORMAT)
end

Instance Attribute Details

#dateObject (readonly)

Returns the value of attribute date.



8
9
10
# File 'app/services/auth/time_header.rb', line 8

def date
  @date
end

#timeObject (readonly)

Returns the value of attribute time.



8
9
10
# File 'app/services/auth/time_header.rb', line 8

def time
  @time
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



8
9
10
# File 'app/services/auth/time_header.rb', line 8

def timestamp
  @timestamp
end