Class: HereOrThere::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/here_or_there/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stdout, stderr, status) ⇒ Response

Returns a new instance of Response.



5
6
7
8
9
# File 'lib/here_or_there/response.rb', line 5

def initialize stdout, stderr, status
  @stdout = stdout
  @stderr = stderr
  @status = status
end

Instance Attribute Details

#statusObject (readonly)

Returns the value of attribute status.



3
4
5
# File 'lib/here_or_there/response.rb', line 3

def status
  @status
end

#stderrObject (readonly)

Returns the value of attribute stderr.



3
4
5
# File 'lib/here_or_there/response.rb', line 3

def stderr
  @stderr
end

#stdoutObject (readonly)

Returns the value of attribute stdout.



3
4
5
# File 'lib/here_or_there/response.rb', line 3

def stdout
  @stdout
end

Instance Method Details

#[](key) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/here_or_there/response.rb', line 11

def [] key
  case key
  when 0 then stdout
  when 1 then stderr
  when 2 then status
  else
    nil
  end
end

#success?Boolean

Returns:

  • (Boolean)


21
22
23
24
25
26
27
# File 'lib/here_or_there/response.rb', line 21

def success?
  if status.respond_to? :success?
    status.success?
  else
    status
  end
end