Class: Warp::Dir::App::Response::Type

Inherits:
Struct
  • Object
show all
Defined in:
lib/warp/dir/app/response.rb

Overview

Use Case exit code stream


Information / Help / List 0 STDOUT Error occured 1 STDERR Execute Shell Command 2 STDOUT

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#exit_codeObject

Returns the value of attribute exit_code

Returns:

  • (Object)

    the current value of exit_code



14
15
16
# File 'lib/warp/dir/app/response.rb', line 14

def exit_code
  @exit_code
end

#streamObject

Returns the value of attribute stream

Returns:

  • (Object)

    the current value of stream



14
15
16
# File 'lib/warp/dir/app/response.rb', line 14

def stream
  @stream
end

Instance Method Details



15
16
17
18
19
20
21
22
23
24
# File 'lib/warp/dir/app/response.rb', line 15

def print(msg)
  under_shell = ::Warp::Dir.eval_context?
  if msg == ' '
    under_shell ? stream.printf(%Q{printf '\\n'; }) : stream.printf("\n")
  else
    msg.split("\n").each do |line|
      under_shell ? stream.printf(%Q{printf -- '#{line.gsub(/['`]/, '\"')}\\n';}) : stream.printf("#{line}\n")
    end
  end
end

#to_sObject



26
27
28
# File 'lib/warp/dir/app/response.rb', line 26

def to_s
  "code:#{exit_code}, stream:#{stream == STDOUT ? "STDOUT" : "STDERR"}"
end