Class: Mysqlknife::Parameter::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/mysqlknife/parameter/base.rb

Direct Known Subclasses

Command, Config, Console, Describe

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



8
9
10
11
12
# File 'lib/mysqlknife/parameter/base.rb', line 8

def initialize
  @command = Mysqlknife::Command.new
  @config  = Mysqlknife::Configs.instance
  @mysql   = Mysqlknife::Mysql.new
end

Instance Attribute Details

#connection=(value) ⇒ Object (writeonly)

Sets the attribute connection

Parameters:

  • value

    the value to set the attribute connection to.



6
7
8
# File 'lib/mysqlknife/parameter/base.rb', line 6

def connection=(value)
  @connection = value
end

#host=(value) ⇒ Object (writeonly)

Sets the attribute host

Parameters:

  • value

    the value to set the attribute host to.



6
7
8
# File 'lib/mysqlknife/parameter/base.rb', line 6

def host=(value)
  @host = value
end

Instance Method Details

#connectionsObject



14
15
16
17
18
19
20
21
# File 'lib/mysqlknife/parameter/base.rb', line 14

def connections
  if @connection.nil?
    puts "Connections:"
    @config.connections.each do |conn|
      puts " - #{conn}"
    end
  end
end

#hostsObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/mysqlknife/parameter/base.rb', line 23

def hosts
  if @connection.nil? == false &&
     @host.nil?       == true
    @config.connection(@connection)
    puts "Hosts for connection: #{@connection}"
    if @config.hosts.nil? == false &&
       @config.hosts.count > 0 &&
       @config.hosts.is_a?(Array)
      @config.hosts.each do |host|
        puts " - #{host}"
      end
    end
  end
end