Sha256: 5a5b59848cb6519299078ff54181fd34dc971b9035f13c6ec87f225e8fa50d0a

Contents?: true

Size: 808 Bytes

Versions: 2

Compression:

Stored size: 808 Bytes

Contents

require 'aws-sdk'


module AwsDump
  class IpPermission < Hash
    def initialize(security_group, ip_permission)
      @security_group = security_group
      @ip_permission = ip_permission
      self[:protocol] = ip_permission.protocol
      self[:port_range] = ip_permission.port_range
      self[:groups] = groups
      self[:ip_ranges] = ip_ranges.sort
    end

    def protocol_port_range
      "#{self[:protocol]}-#{self[:port_range]}"
    end

    def <=>(other)
      protocol_port_range <=> other.protocol_port_range
    end

    def groups
      @ip_permission.groups.collect do |group|
        {
          :name => group.name,
          :id => group.id
        }
      end
    end

    def ip_ranges
      @ip_permission.ip_ranges.collect do |ip_range|
        ip_range
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aws_dump-0.0.2 lib/aws_dump/ip_permission.rb
aws_dump-0.0.1 lib/aws_dump/ip_permission.rb