class AwsEc2List::ParseOption

Public Instance Methods

call() click to toggle source
# File lib/aws_ec2_list/parse_option.rb, line 8
def call
  return {} if args.nil? || args.flatten.empty?
  option_string_to_hash
end

Private Instance Methods

multi_option() click to toggle source
# File lib/aws_ec2_list/parse_option.rb, line 28
def multi_option
  option_string.split("--").reject { |o| o.empty? }
end
option_string() click to toggle source
# File lib/aws_ec2_list/parse_option.rb, line 32
def option_string
  args.flatten.join(" ")
end
option_string_to_hash() click to toggle source
# File lib/aws_ec2_list/parse_option.rb, line 14
def option_string_to_hash
  hash = Hash[*parse_array]

  hash.keys.each do |key|
    hash[key.to_sym] = hash.delete(key).strip
  end

  hash
end
parse_array() click to toggle source
# File lib/aws_ec2_list/parse_option.rb, line 24
def parse_array
  multi_option.map{ |opt| opt.split("=") }.flatten
end