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
-
#error(message, stream = $stderr) ⇒ Object
Output an error message to
stream
(defaults to $stderr). -
#output(string, opts = {}) ⇒ Object
Output
string
toopts[:stream]
usingopts[:method]
. -
#take_action! ⇒ Object
After Corrupt::Client#run has setup
@options
, this method determines what action to take.
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(, stream = $stderr) stream.puts 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 |