Class: Traffic

Inherits:
Object
  • Object
show all
Defined in:
lib/ec2/traffic.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ingress, from, to, port_range) ⇒ Traffic

Returns a new instance of Traffic.



4
5
6
7
8
9
# File 'lib/ec2/traffic.rb', line 4

def initialize(ingress, from, to, port_range)
  @ingress = ingress
  @from = from
  @to = to
  @port_range = port_range
end

Instance Attribute Details

#fromObject

Returns the value of attribute from.



2
3
4
# File 'lib/ec2/traffic.rb', line 2

def from
  @from
end

#ingressObject

Returns the value of attribute ingress.



2
3
4
# File 'lib/ec2/traffic.rb', line 2

def ingress
  @ingress
end

#port_rangeObject

Returns the value of attribute port_range.



2
3
4
# File 'lib/ec2/traffic.rb', line 2

def port_range
  @port_range
end

#toObject

Returns the value of attribute to.



2
3
4
# File 'lib/ec2/traffic.rb', line 2

def to
  @to
end

Class Method Details

.grouped(traffic_list) ⇒ Object



27
28
29
30
31
# File 'lib/ec2/traffic.rb', line 27

def self.grouped(traffic_list)
  t = traffic_list.first
  port_range = traffic_list.collect(&:port_range).uniq.join(',')
  Traffic.new(t.ingress, t.from, t.to, port_range)
end

Instance Method Details

#copy(from, to) ⇒ Object



11
12
13
# File 'lib/ec2/traffic.rb', line 11

def copy(from, to)
  Traffic.new(@ingress, from, to, @port_range)
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
18
19
20
21
# File 'lib/ec2/traffic.rb', line 15

def eql?(other)
  if @ingress == other.ingress
    @from == other.from && @to == other.to && @port_range == other.port_range
  else
    @from == other.to && @to == other.from && @port_range == other.port_range
  end
end

#hashObject



23
24
25
# File 'lib/ec2/traffic.rb', line 23

def hash
  @from.hash + @to.hash + @port_range.hash
end