Class: Arn

Inherits:
Object
  • Object
show all
Defined in:
lib/arn_parser.rb

Overview

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(partition, service, region, account, resource) ⇒ Arn

Returns a new instance of Arn.



7
8
9
10
11
12
13
# File 'lib/arn_parser.rb', line 7

def initialize(partition, service, region, , resource)
  @partition = partition
  @service = service
  @region = region
  @account = 
  @resource = resource
end

Instance Attribute Details

#accountObject

Returns the value of attribute account.



5
6
7
# File 'lib/arn_parser.rb', line 5

def 
  @account
end

#partitionObject

Returns the value of attribute partition.



5
6
7
# File 'lib/arn_parser.rb', line 5

def partition
  @partition
end

#regionObject

Returns the value of attribute region.



5
6
7
# File 'lib/arn_parser.rb', line 5

def region
  @region
end

#resourceObject

Returns the value of attribute resource.



5
6
7
# File 'lib/arn_parser.rb', line 5

def resource
  @resource
end

#serviceObject

Returns the value of attribute service.



5
6
7
# File 'lib/arn_parser.rb', line 5

def service
  @service
end

Class Method Details

.parse(arn) ⇒ Object

Raises:

  • (TypeError)


15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/arn_parser.rb', line 15

def self.parse(arn)
  raise TypeError, 'ARN must be supplied as a string' unless arn.is_a?(String)

  arn_components = arn.split(':', 6)
  raise ArgumentError, 'Could not parse ARN' if arn_components.length < 6

  Arn.new arn_components[1],
          arn_components[2],
          arn_components[3],
          arn_components[4],
          arn_components[5]
end