Class: Moku::Status

Inherits:
Object
  • Object
show all
Defined in:
lib/moku/status.rb

Overview

A generic wrapper over the result of some operation.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(success, output = "", error = "") ⇒ Status


19
20
21
22
23
# File 'lib/moku/status.rb', line 19

def initialize(success, output = "", error = "")
  @success = success
  @output = output
  @error = error
end

Instance Attribute Details

#errorString (readonly)

Any error reported


27
28
29
# File 'lib/moku/status.rb', line 27

def error
  @error
end

#outputString (readonly)

Any error reported


27
28
29
# File 'lib/moku/status.rb', line 27

def output
  @output
end

Class Method Details

.failure(error = "") ⇒ Object


12
13
14
# File 'lib/moku/status.rb', line 12

def self.failure(error = "")
  new(false, "", error)
end

.success(output = "") ⇒ Object


8
9
10
# File 'lib/moku/status.rb', line 8

def self.success(output = "")
  new(true, output, "")
end

Instance Method Details

#eql?(other) ⇒ Boolean Also known as: ==


34
35
36
37
38
# File 'lib/moku/status.rb', line 34

def eql?(other)
  success? == other.success? &&
    output == other.output &&
    error == other.error
end

#success?Boolean


30
31
32
# File 'lib/moku/status.rb', line 30

def success?
  @success
end