Module: Corrupt::ClientHelpers

Included in:
Client
Defined in:
lib/corrupt/client/helpers.rb

Overview

A few helpful methods, mainly used in the command-line Client.

Instance Method Summary collapse

Instance Method Details

#error(message, stream = $stderr) ⇒ Object

Output an error message to stream (defaults to $stderr).



6
7
8
# File 'lib/corrupt/client/helpers.rb', line 6

def error(message, stream = $stderr)
  stream.puts message
end

#output(string, opts = {}) ⇒ Object

Output string to opts[:stream] using opts[:method].



11
12
13
14
15
# File 'lib/corrupt/client/helpers.rb', line 11

def output(string, opts = {})
  opts[:method] ||= 'puts'
  opts[:stream] ||= $stdout
  opts[:stream].send(opts[:method], string)
end

#take_action!Object

After Corrupt::Client#run has setup @options, this method determines what action to take.



19
20
21
# File 'lib/corrupt/client/helpers.rb', line 19

def take_action!
  Corrupt::Generators::App.new(@options[:path]) if @options[:path]
end