Class: Fog::Bouncer::Source
- Inherits:
-
Object
- Object
- Fog::Bouncer::Source
show all
- Defined in:
- lib/fog/bouncer/source.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(source, group, &block) ⇒ Source
Returns a new instance of Source.
7
8
9
10
11
12
13
14
|
# File 'lib/fog/bouncer/source.rb', line 7
def initialize(source, group, &block)
@source = source
@group = group
if block_given?
@local = true
instance_eval(&block)
end
end
|
Instance Attribute Details
#group ⇒ Object
Returns the value of attribute group.
4
5
6
|
# File 'lib/fog/bouncer/source.rb', line 4
def group
@group
end
|
#local ⇒ Object
38
39
40
|
# File 'lib/fog/bouncer/source.rb', line 38
def local
@local ||= false
end
|
#remote ⇒ Object
54
55
56
|
# File 'lib/fog/bouncer/source.rb', line 54
def remote
@remote ||= false
end
|
#source ⇒ Object
Returns the value of attribute source.
4
5
6
|
# File 'lib/fog/bouncer/source.rb', line 4
def source
@source
end
|
Instance Method Details
#==(other) ⇒ Object
62
63
64
65
66
|
# File 'lib/fog/bouncer/source.rb', line 62
def ==(other)
source == other.source &&
group == other.group &&
protocols.sort! == other.protocols.sort!
end
|
#add_protocol(type, port) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/fog/bouncer/source.rb', line 20
def add_protocol(type, port)
protocol = protocols.find { |p| p.match(type, port) }
if protocol.nil?
protocol = case type.to_sym
when :icmp
Fog::Bouncer::Protocols::ICMP.new(port, self)
when :tcp
Fog::Bouncer::Protocols::TCP.new(port, self)
when :udp
Fog::Bouncer::Protocols::UDP.new(port, self)
end
protocols << protocol
end
protocol
end
|
16
17
18
|
# File 'lib/fog/bouncer/source.rb', line 16
def
protocols.select { |protocol| !protocol.local? }
end
|
#inspect ⇒ Object
68
69
70
|
# File 'lib/fog/bouncer/source.rb', line 68
def inspect
"<#{self.class.name} @source=#{source.inspect} @local=#{local} @remote=#{remote} @protocols=#{protocols.inspect}>"
end
|
#local? ⇒ Boolean
42
43
44
|
# File 'lib/fog/bouncer/source.rb', line 42
def local?
!!local
end
|
#missing ⇒ Object
46
47
48
|
# File 'lib/fog/bouncer/source.rb', line 46
def missing
protocols.select { |protocol| protocol.local? && !protocol.remote? }
end
|
#protocols ⇒ Object
50
51
52
|
# File 'lib/fog/bouncer/source.rb', line 50
def protocols
@protocols ||= []
end
|
#remote? ⇒ Boolean
58
59
60
|
# File 'lib/fog/bouncer/source.rb', line 58
def remote?
!!remote
end
|