Class: Fog::Bouncer::Protocol
- Inherits:
-
Object
- Object
- Fog::Bouncer::Protocol
show all
- Defined in:
- lib/fog/bouncer/protocols.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(port, source) ⇒ Protocol
Returns a new instance of Protocol.
15
16
17
18
19
|
# File 'lib/fog/bouncer/protocols.rb', line 15
def initialize(port, source)
@from, @to = Protocol.range(port)
@source = source
validate
end
|
Instance Attribute Details
#from ⇒ Object
Returns the value of attribute from.
4
5
6
|
# File 'lib/fog/bouncer/protocols.rb', line 4
def from
@from
end
|
#local ⇒ Object
Returns the value of attribute local.
4
5
6
|
# File 'lib/fog/bouncer/protocols.rb', line 4
def local
@local
end
|
#remote ⇒ Object
37
38
39
|
# File 'lib/fog/bouncer/protocols.rb', line 37
def remote
@remote ||= false
end
|
#source ⇒ Object
Returns the value of attribute source.
4
5
6
|
# File 'lib/fog/bouncer/protocols.rb', line 4
def source
@source
end
|
#to ⇒ Object
Returns the value of attribute to.
4
5
6
|
# File 'lib/fog/bouncer/protocols.rb', line 4
def to
@to
end
|
Class Method Details
.range(port) ⇒ Object
7
8
9
10
11
12
13
|
# File 'lib/fog/bouncer/protocols.rb', line 7
def self.range(port)
if port.is_a?(Range)
[port.begin, port.end]
else
[port, port]
end
end
|
Instance Method Details
#<=>(other) ⇒ Object
55
56
57
|
# File 'lib/fog/bouncer/protocols.rb', line 55
def <=>(other)
[from, to] <=> [other.from, other.to]
end
|
#==(other) ⇒ Object
49
50
51
52
53
|
# File 'lib/fog/bouncer/protocols.rb', line 49
def ==(other)
type == other.type &&
from == other.from &&
to == other.to
end
|
#group ⇒ Object
21
22
23
|
# File 'lib/fog/bouncer/protocols.rb', line 21
def group
source.group
end
|
#inspect ⇒ Object
59
60
61
|
# File 'lib/fog/bouncer/protocols.rb', line 59
def inspect
"<#{self.class.name} @from=#{from.inspect} @to=#{to.inspect} @local=#{local} @remote=#{remote}>"
end
|
#local? ⇒ Boolean
29
30
31
|
# File 'lib/fog/bouncer/protocols.rb', line 29
def local?
!!local
end
|
#match(type, port) ⇒ Object
33
34
35
|
# File 'lib/fog/bouncer/protocols.rb', line 33
def match(type, port)
type.to_s == self.type && Protocol.range(port) == [from, to]
end
|
#remote? ⇒ Boolean
41
42
43
|
# File 'lib/fog/bouncer/protocols.rb', line 41
def remote?
!!remote
end
|
#to_log ⇒ Object
63
64
65
|
# File 'lib/fog/bouncer/protocols.rb', line 63
def to_log
{ source: source.source, protocol: type, from: from, to: to }
end
|
#type ⇒ Object
45
46
47
|
# File 'lib/fog/bouncer/protocols.rb', line 45
def type
@type ||= self.class.to_s.gsub("Fog::Bouncer::Protocols::", "").downcase
end
|