Class: NagiosHerald::Message::IRC

Inherits:
NagiosHerald::Message show all
Defined in:
lib/nagios-herald/messages/irc.rb

Instance Attribute Summary collapse

Attributes inherited from NagiosHerald::Message

#content, #recipients

Instance Method Summary collapse

Methods inherited from NagiosHerald::Message

inherited, message_types

Methods included from Util

#get_nagios_var, get_script_path, load_helper, underscore_to_camel_case, #unescape_text

Methods included from Logging

#configure_logger_for, #logger, #logger_for

Constructor Details

#initialize(recipients, options = {}) ⇒ IRC

Public: Initializes a new Message::IRC object.

recipients - A list of recipients for this message. options - The options hash from Executor. FIXME: Is that ^^ necessary now with Config.config available?

Returns a new Message::IRC object.



17
18
19
20
# File 'lib/nagios-herald/messages/irc.rb', line 17

def initialize(recipients, options = {})
  @text = ""
  super(recipients, options)
end

Instance Attribute Details

#textObject

Returns the value of attribute text.



8
9
10
# File 'lib/nagios-herald/messages/irc.rb', line 8

def text
  @text
end

Instance Method Details

#curate_textObject

Public: Generates the text portion of the content hash.

Returns the full text portion of the content hash.



25
26
27
28
29
30
# File 'lib/nagios-herald/messages/irc.rb', line 25

def curate_text
  # FIXME: Gonna need to chomp newlines
  @text += self.content[:text][:host_info]
  @text += self.content[:text][:state_info]
  @text += self.content[:text][:alert_ack_url]
end

Public: Prints the text content to the terminal. Useful for debugging.

Returns nothing.



36
37
38
# File 'lib/nagios-herald/messages/irc.rb', line 36

def print
  puts @text
end

#sendObject

Public: Sends the IRC message.

Returns nothing.



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/nagios-herald/messages/irc.rb', line 43

def send
  curate_text
  if @no_send
    self.print
    return
  end

  # TODO: Actually make this send to an IRC server
  # I expect the IRC server will be a value in the config
  self.print
end