Class: Aruba::Platforms::Announcer
- Inherits:
 - 
      Object
      
        
- Object
 - Aruba::Platforms::Announcer
 
 
- Defined in:
 - lib/aruba/platforms/announcer.rb
 
Overview
Announcer
Defined Under Namespace
Classes: BaseAnnouncer, KernelPutsAnnouncer, PutsAnnouncer
Instance Method Summary collapse
- 
  
    
      #activate(*chns)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Activate a channel.
 - 
  
    
      #activated?(channel)  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    
Check if channel is activated.
 - 
  
    
      #announce(channel, *args) { ... } ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Announce information to channel.
 - 
  
    
      #initialize  ⇒ Announcer 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of Announcer.
 - 
  
    
      #mode  ⇒ Symbol 
    
    
  
  
  
  
  
  
  
  
  
    
Fecth mode of announcer.
 - 
  
    
      #mode=(m)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Change mode of announcer.
 - 
  
    
      #reset  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Reset announcer.
 
Constructor Details
#initialize ⇒ Announcer
Returns a new instance of Announcer.
      69 70 71 72 73 74 75 76 77 78 79 80 81  | 
    
      # File 'lib/aruba/platforms/announcer.rb', line 69 def initialize @announcers = [] @announcers << PutsAnnouncer.new @announcers << KernelPutsAnnouncer.new @colorizer = Aruba::Colorizer.new @announcer = @announcers.first @channels = {} @output_formats = {} after_init end  | 
  
Instance Method Details
#activate(*chns) ⇒ Object
Activate a channel
      160 161 162 163 164  | 
    
      # File 'lib/aruba/platforms/announcer.rb', line 160 def activate(*chns) chns.flatten.each { |c| channels[c.to_sym] = true } self end  | 
  
#activated?(channel) ⇒ Boolean
Check if channel is activated
      152 153 154  | 
    
      # File 'lib/aruba/platforms/announcer.rb', line 152 def activated?(channel) channels[channel.to_sym] == true end  | 
  
#announce(channel, *args) { ... } ⇒ Object
Announce information to channel
      177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204  | 
    
      # File 'lib/aruba/platforms/announcer.rb', line 177 def announce(channel, *args) channel = channel.to_sym the_output_format = if output_formats.key? channel output_formats[channel] else proc { |v| format('%s', v) } end return unless activated?(channel) begin if block_given? value = yield args << value end = the_output_format.call(*args) += "\n" = colorizer.cyan() rescue NotImplementedError => e = "Error fetching announced value for #{channel}: #{e.}" end announcer.announce() nil end  | 
  
#mode ⇒ Symbol
Fecth mode of announcer
      144 145 146  | 
    
      # File 'lib/aruba/platforms/announcer.rb', line 144 def mode @announcer.mode end  | 
  
#mode=(m) ⇒ Object
Change mode of announcer
      137 138 139  | 
    
      # File 'lib/aruba/platforms/announcer.rb', line 137 def mode=(m) @announcer = @announcers.find { |a| a.mode? m.to_sym } end  | 
  
#reset ⇒ Object
Reset announcer
      129 130 131  | 
    
      # File 'lib/aruba/platforms/announcer.rb', line 129 def reset @announcer = @announcers.first end  |