Exception: Protocol::CheckFailed

Inherits:
ProtocolError show all
Includes:
Enumerable, CheckError
Defined in:
lib/protocol/errors.rb

Overview

This exception collects CheckError exceptions and mixes in Enumerable for further processing of them.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*errors) ⇒ CheckFailed

Returns a new instance of CheckFailed.



60
61
62
# File 'lib/protocol/errors.rb', line 60

def initialize(*errors)
  @errors = errors
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



64
65
66
# File 'lib/protocol/errors.rb', line 64

def errors
  @errors
end

Instance Method Details

#<<(check_error) ⇒ Object

Add check_error to this CheckFailed instance.



73
74
75
76
# File 'lib/protocol/errors.rb', line 73

def <<(check_error)
  @errors << check_error
  self
end

#each_error(&block) ⇒ Object Also known as: each

Iterate over all errors of this CheckFailed instance and pass each one to block.



80
81
82
# File 'lib/protocol/errors.rb', line 80

def each_error(&block)
  errors.each(&block)
end

#empty?Boolean

Return true, if this CheckFailed doesn’t contain any errors (yet). Otherwise false is returned.

Returns:

  • (Boolean)


68
69
70
# File 'lib/protocol/errors.rb', line 68

def empty?
  errors.empty?
end

#inspectObject



91
92
93
# File 'lib/protocol/errors.rb', line 91

def inspect
  "#<#{self.class.name}: #{errors.map { |e| e.inspect} * '|'}"
end

#to_sObject



87
88
89
# File 'lib/protocol/errors.rb', line 87

def to_s
  errors * "|"
end