Class: Shmac::AuthorizationHeader

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/shmac/authorization_header.rb

Defined Under Namespace

Classes: FormatError

Constant Summary collapse

AUTH_HEADER_PATTERN =
/(.+) (.+):(.+)$/

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ AuthorizationHeader

Returns a new instance of AuthorizationHeader.



14
15
16
17
# File 'lib/shmac/authorization_header.rb', line 14

def initialize value
  @value = value
  self.parts = value
end

Instance Attribute Details

#partsObject

Returns the value of attribute parts.



8
9
10
# File 'lib/shmac/authorization_header.rb', line 8

def parts
  @parts
end

Class Method Details

.generate(organization:, access_key:, signature:) ⇒ Object



10
11
12
# File 'lib/shmac/authorization_header.rb', line 10

def self.generate organization:, access_key:, signature:
  new("%s %s:%s" % [organization, access_key, signature])
end

Instance Method Details

#==(other) ⇒ Object



19
20
21
# File 'lib/shmac/authorization_header.rb', line 19

def == other
  other.is_a?(self.class) && self.to_s == other.to_s
end

#access_key_idObject



40
41
42
# File 'lib/shmac/authorization_header.rb', line 40

def access_key_id
  parts[2]
end

#organizationObject



36
37
38
# File 'lib/shmac/authorization_header.rb', line 36

def organization
  parts[1]
end

#signatureObject



44
45
46
# File 'lib/shmac/authorization_header.rb', line 44

def signature
  parts[3]
end

#to_sObject



23
24
25
# File 'lib/shmac/authorization_header.rb', line 23

def to_s
  @value
end