Class: Arn
- Inherits:
-
Object
- Object
- Arn
- Defined in:
- lib/arn_parser.rb
Overview
Instance Attribute Summary collapse
-
#account ⇒ Object
Returns the value of attribute account.
-
#partition ⇒ Object
Returns the value of attribute partition.
-
#region ⇒ Object
Returns the value of attribute region.
-
#resource ⇒ Object
Returns the value of attribute resource.
-
#service ⇒ Object
Returns the value of attribute service.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(partition, service, region, account, resource) ⇒ Arn
constructor
A new instance of Arn.
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, account, resource) @partition = partition @service = service @region = region @account = account @resource = resource end |
Instance Attribute Details
#account ⇒ Object
Returns the value of attribute account.
5 6 7 |
# File 'lib/arn_parser.rb', line 5 def account @account end |
#partition ⇒ Object
Returns the value of attribute partition.
5 6 7 |
# File 'lib/arn_parser.rb', line 5 def partition @partition end |
#region ⇒ Object
Returns the value of attribute region.
5 6 7 |
# File 'lib/arn_parser.rb', line 5 def region @region end |
#resource ⇒ Object
Returns the value of attribute resource.
5 6 7 |
# File 'lib/arn_parser.rb', line 5 def resource @resource end |
#service ⇒ Object
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
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 |