Class: Naplug::Output

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text_output = 'uninitialized plugin') ⇒ Output

Returns a new instance of Output.



11
12
13
14
# File 'lib/naplug/output.rb', line 11

def initialize(text_output = 'uninitialized plugin')
  @text_output = text_output
  @long_text = []
end

Instance Attribute Details

#long_textObject (readonly)

Returns the value of attribute long_text.



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

def long_text
  @long_text
end

#text_outputObject

Implements Text Output and Long Text elements from the Nagios Plugin API



8
9
10
# File 'lib/naplug/output.rb', line 8

def text_output
  @text_output
end

Instance Method Details

#push(*long_text) ⇒ Array<String>

Pushes the given long text strings on the end of long text. Returns the long_text

Returns:

  • (Array<String>)

    array of long text strings



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

def push(*long_text)
  @long_text.push long_text
end

#to_s(output = :text_output) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/naplug/output.rb', line 22

def to_s(output = :text_output)
  case output
    when :text_output then @text_output
    when :long_text   then @long_text.join "\n"
    else nil
  end
end