Class: Whenever::Output::Redirection

Inherits:
Object
  • Object
show all
Defined in:
lib/whenever/output_redirection.rb

Instance Method Summary collapse

Constructor Details

#initialize(output) ⇒ Redirection

Returns a new instance of Redirection.



4
5
6
# File 'lib/whenever/output_redirection.rb', line 4

def initialize(output)
  @output = output
end

Instance Method Details

#to_sObject



8
9
10
11
12
13
14
15
16
17
# File 'lib/whenever/output_redirection.rb', line 8

def to_s
  return '' unless defined?(@output)
  case @output
    when String   then redirect_from_string
    when Hash     then redirect_from_hash
    when NilClass then ">> /dev/null 2>&1"
    when Proc     then @output.call
    else ''
  end 
end