Class: TBM::Target
- Inherits:
-
Object
- Object
- TBM::Target
- Defined in:
- lib/TBM/target.rb
Overview
A target defines a tunnel or set of tunnels that can be created by invoking one or more names assigned to the target.
It has a name, a host, a user, and one or more tunnels well as an optional list of aliases.
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#tunnels ⇒ Object
readonly
Returns the value of attribute tunnels.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
-
#add_alias(name) ⇒ Object
Adds an alias to the list of recognized aliases supported by the target.
-
#add_tunnel(tunnel) ⇒ Object
Adds a tunnel to the target.
- #each_tunnel(&block) ⇒ Object
- #has_name?(name) ⇒ Boolean
- #has_tunnels? ⇒ Boolean
-
#initialize(name, host, username) ⇒ Target
constructor
A new instance of Target.
- #to_s ⇒ Object
Constructor Details
#initialize(name, host, username) ⇒ Target
10 11 12 13 14 15 16 |
# File 'lib/TBM/target.rb', line 10 def initialize( name, host, username ) @name = name @host = host @username = username @tunnels = [] @aliases = [] end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
8 9 10 |
# File 'lib/TBM/target.rb', line 8 def host @host end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/TBM/target.rb', line 8 def name @name end |
#tunnels ⇒ Object (readonly)
Returns the value of attribute tunnels.
8 9 10 |
# File 'lib/TBM/target.rb', line 8 def tunnels @tunnels end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
8 9 10 |
# File 'lib/TBM/target.rb', line 8 def username @username end |
Instance Method Details
#add_alias(name) ⇒ Object
Adds an alias to the list of recognized aliases supported by the target.
28 29 30 |
# File 'lib/TBM/target.rb', line 28 def add_alias( name ) @aliases << name end |
#add_tunnel(tunnel) ⇒ Object
Adds a tunnel to the target.
21 22 23 |
# File 'lib/TBM/target.rb', line 21 def add_tunnel( tunnel ) @tunnels << tunnel end |
#each_tunnel(&block) ⇒ Object
36 37 38 |
# File 'lib/TBM/target.rb', line 36 def each_tunnel( &block ) @tunnels.each { |tunnel| yield tunnel } end |
#has_name?(name) ⇒ Boolean
32 33 34 |
# File 'lib/TBM/target.rb', line 32 def has_name?( name ) ( @name == name ) || ( @aliases.include? name ) end |
#has_tunnels? ⇒ Boolean
48 49 50 |
# File 'lib/TBM/target.rb', line 48 def has_tunnels? !@tunnels.empty? end |
#to_s ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/TBM/target.rb', line 40 def to_s if @aliases.empty? @name else "#{@name} (#{@aliases.join(', ')})" end end |