Module: AwsEc2List
- Defined in:
- lib/aws_ec2_list.rb,
lib/aws_ec2_list/version.rb
Defined Under Namespace
Classes: DescribeInstances, Instance
Constant Summary
collapse
- VERSION =
"0.2.1"
Class Method Summary
collapse
Class Method Details
.option_string_to_hash(option_string) ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/aws_ec2_list.rb', line 34
def self.option_string_to_hash(option_string)
option_array = option_string.split("--").reject { |o| o.empty? }
option_array = option_array.map{ |opt| opt.split("=") }.flatten
option_hash = Hash[*option_array]
option_hash.keys.each do |key|
option_hash[key.to_sym] = option_hash.delete(key)
end
option_hash
end
|
.parse_args(args) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/aws_ec2_list.rb', line 17
def self.parse_args(args)
return nil if args.empty?
return args.first if args.first.is_a?(Hash)
option_string, default_args = args
option_string = option_string.first
if option_string && default_args
option_hash = option_string_to_hash(option_string)
option_hash.merge(default_args)
elsif option_string
option_string_to_hash(option_string)
end
end
|