Class: Tell

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

Constant Summary collapse

VERSION =
"0.0.1"
FORMAT =

ANSI Colors for a better user experience. 1;32m - Green 1;37m - White

"\e[1;32m %10s\e[1;37m  %s"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(servers = [], &block) ⇒ Tell

Returns a new instance of Tell.



11
12
13
14
15
16
# File 'lib/tell.rb', line 11

def initialize(servers = [], &block)
  @servers = servers
  @commands = []

  instance_eval(&block) if block_given?
end

Instance Attribute Details

#serversObject (readonly)

Returns the value of attribute servers.



9
10
11
# File 'lib/tell.rb', line 9

def servers
  @servers
end

Instance Method Details

#execute(command) ⇒ Object



18
19
20
# File 'lib/tell.rb', line 18

def execute(command)
  @commands << command
end

#runObject



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/tell.rb', line 22

def run
  silence!

  servers.each do |server|
    log :connect, server

    @commands.each do |command|
      log :run, command

      display exec(server, command)
    end
  end
end