Class: Printer

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(executor) ⇒ Printer

Returns a new instance of Printer.



3
4
5
6
# File 'lib/jssh/printer.rb', line 3

def initialize(executor)
    self.instant=true
    @executor=executor
end

Instance Attribute Details

#instantObject

Returns the value of attribute instant.



2
3
4
# File 'lib/jssh/printer.rb', line 2

def instant
  @instant
end

Instance Method Details

#finished?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/jssh/printer.rb', line 22

def finished?
    @memo.empty?
end


11
12
13
14
15
16
17
18
19
20
21
# File 'lib/jssh/printer.rb', line 11

def print(host,content,is_end)
    if self.instant
        lambda{ @executor.puts ("="*20+host+"="*20).to_yellow; @memo[host]='' }.call unless @memo[host]
        @executor.puts content if content
        @memo.delete host if is_end
    else
        @memo[host]=("="*20+host+"="*20).to_yellow+"\n"  unless @memo[host]
        @memo[host] << content if content
        lambda{ @executor.puts @memo[host]; @memo.delete host }.call if is_end
    end
end

#submit_jobs(hosts) ⇒ Object



7
8
9
10
# File 'lib/jssh/printer.rb', line 7

def submit_jobs(hosts)
    @memo={}
    hosts.each{|j| @memo[j]=nil }
end