Class: ChefApply::UI::PlainTextHeader

Inherits:
Object
  • Object
show all
Defined in:
lib/chef_apply/ui/plain_text_header.rb

Instance Method Summary collapse

Constructor Details

#initialize(format, opts) ⇒ PlainTextHeader

Returns a new instance of PlainTextHeader.



22
23
24
25
26
27
# File 'lib/chef_apply/ui/plain_text_header.rb', line 22

def initialize(format, opts)
  @format = format
  @output = opts[:output]
  @children = {}
  @threads = []
end

Instance Method Details

#auto_spinObject



35
36
37
38
39
40
41
42
# File 'lib/chef_apply/ui/plain_text_header.rb', line 35

def auto_spin
  msg = @format.gsub(/:spinner/, " HEADER ")
  @output.puts(msg)
  @children.each do |child, block|
    @threads << Thread.new { block.call(child) }
  end
  @threads.each(&:join)
end

#register(child_format, child_opts, &block) ⇒ Object



29
30
31
32
33
# File 'lib/chef_apply/ui/plain_text_header.rb', line 29

def register(child_format, child_opts, &block)
  child_opts[:output] = @output
  child = PlainTextElement.new(child_format, child_opts)
  @children[child] = block
end