Class: Mysqlknife::Parameters

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeParameters

Returns a new instance of Parameters.



8
9
10
# File 'lib/mysqlknife/parameters.rb', line 8

def initialize
  @cnf = Configs.instance
end

Instance Attribute Details

#connection=(value) ⇒ Object (writeonly)

Sets the attribute connection

Parameters:

  • value

    the value to set the attribute connection to.



5
6
7
# File 'lib/mysqlknife/parameters.rb', line 5

def connection=(value)
  @connection = value
end

#hostObject

Returns the value of attribute host.



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

def host
  @host
end

#toolObject

Returns the value of attribute tool.



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

def tool
  @tool
end

Instance Method Details

#connection_detailsObject



18
19
20
21
22
# File 'lib/mysqlknife/parameters.rb', line 18

def connection_details
  unless @connection.nil?
    puts @cnf.show(@connection)
  end
end

#connectionsObject



12
13
14
15
16
# File 'lib/mysqlknife/parameters.rb', line 12

def connections
  if @connection.nil?
    puts @cnf.connections
  end
end

#host_selectedObject



46
47
48
49
50
51
52
53
54
55
# File 'lib/mysqlknife/parameters.rb', line 46

def host_selected
  if @connection.nil? == false &&
     @host.nil?       == false
    @cnf.hosts(@connection).each do |host|
      return @host = host if host.include?(@host)
    end

    false
  end
end

#hostsObject



24
25
26
27
28
29
# File 'lib/mysqlknife/parameters.rb', line 24

def hosts
  if @connection.nil? == false &&
     @host.nil?       == true
    puts @cnf.hosts(@connection)
  end
end

#slave_selectedObject



57
58
59
60
61
62
63
64
65
66
# File 'lib/mysqlknife/parameters.rb', line 57

def slave_selected
  if @connection.nil? == false &&
     @host.nil?       == false
    @cnf.slaves(@connection).each do |host|
      return @host = host if host.include?(@host)
    end

    false
  end
end

#slavesObject



31
32
33
34
35
36
# File 'lib/mysqlknife/parameters.rb', line 31

def slaves
  if @connection.nil? == false &&
     @host.nil?       == true
    puts @cnf.slaves(@connection)
  end
end

#tool_selectedObject



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/mysqlknife/parameters.rb', line 68

def tool_selected
  if @connection.nil? == false &&
     @host.nil?       == false &&
     @tool.nil?       == false &&
     @cnf.tools(@connection).include?(@tool)
    @cnf.hosts(@connection).each do |host|
      if host.include?(@host)
        @host = host
        @tool = @cnf.tool(@connection, @tool)

        return @tool
      end
    end
  end
end

#toolsObject



38
39
40
41
42
43
44
# File 'lib/mysqlknife/parameters.rb', line 38

def tools
  if @connection.nil? == false &&
     @host.nil?       == false &&
     @tool.nil?       == true
    puts @cnf.tools(@connection)
  end
end