Class: Train::Transports::Helpers::Azure::SubscriptionNumberFileParser
- Inherits:
-
Object
- Object
- Train::Transports::Helpers::Azure::SubscriptionNumberFileParser
- Defined in:
- lib/train/transports/helpers/azure/subscription_number_file_parser.rb
Instance Method Summary collapse
-
#initialize(index, credentials) ⇒ SubscriptionNumberFileParser
constructor
A new instance of SubscriptionNumberFileParser.
- #subscription_id ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(index, credentials) ⇒ SubscriptionNumberFileParser
Returns a new instance of SubscriptionNumberFileParser.
5 6 7 8 9 10 |
# File 'lib/train/transports/helpers/azure/subscription_number_file_parser.rb', line 5 def initialize(index, credentials) @index = index @credentials = credentials validate! end |
Instance Method Details
#subscription_id ⇒ Object
22 23 24 |
# File 'lib/train/transports/helpers/azure/subscription_number_file_parser.rb', line 22 def subscription_id @subscription_id ||= @credentials.sections[@index - 1] end |
#validate! ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/train/transports/helpers/azure/subscription_number_file_parser.rb', line 12 def validate! if @index == 0 raise "Index must be greater than 0." end if @index > @credentials.sections.length raise "Your credentials file only contains #{@credentials.sections.length} subscriptions. You specified number #{@index}." end end |