Class: Ciclope::Host
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
sort by log file names, there is no way to do this by host names, may be there is another way to do this more clean TODO: find the right sort.
-
#_master_log_file ⇒ Object
rename becuse there is a key with the same name.
-
#initialize(connection) ⇒ Host
constructor
A new instance of Host.
- #log_file ⇒ Object
- #name ⇒ Object
- #status ⇒ Object
Constructor Details
#initialize(connection) ⇒ Host
Returns a new instance of Host.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/ciclope/host.rb', line 7 def initialize(connection) @connection = connection @config = @connection.instance_variable_get '@config' # define every key as a method status.keys.each do |m| self.class.send :define_method, m.downcase do status[m] end end end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
5 6 7 |
# File 'lib/ciclope/host.rb', line 5 def config @config end |
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
5 6 7 |
# File 'lib/ciclope/host.rb', line 5 def connection @connection end |
Instance Method Details
#<=>(other) ⇒ Object
sort by log file names, there is no way to do this by host names, may be there is another way to do this more clean TODO: find the right sort
38 39 40 41 42 43 44 45 46 |
# File 'lib/ciclope/host.rb', line 38 def <=>(other) if log_file == other._master_log_file -1 elsif other.log_file == _master_log_file 1 else 0 end end |
#_master_log_file ⇒ Object
rename becuse there is a key with the same name
32 33 34 |
# File 'lib/ciclope/host.rb', line 32 def _master_log_file cleanfy_log_name relay_master_log_file.split('.').first end |
#log_file ⇒ Object
27 28 29 |
# File 'lib/ciclope/host.rb', line 27 def log_file cleanfy_log_name relay_log_file.split('.').first end |
#name ⇒ Object
19 20 21 |
# File 'lib/ciclope/host.rb', line 19 def name @config[:host] end |
#status ⇒ Object
23 24 25 |
# File 'lib/ciclope/host.rb', line 23 def status @connection.select_one 'SHOW SLAVE STATUS' end |