Class: Harbor::Errors

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/harbor/errors.rb

Instance Method Summary collapse

Constructor Details

#initialize(errors = []) ⇒ Errors

Returns a new instance of Errors.



7
8
9
# File 'lib/harbor/errors.rb', line 7

def initialize(errors = [])
  @errors = errors
end

Instance Method Details

#+(other) ⇒ Object



37
38
39
# File 'lib/harbor/errors.rb', line 37

def +(other)
  Errors.new((errors + other.errors).uniq)
end

#<<(message) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/harbor/errors.rb', line 15

def <<(message)
  if message.is_a?(String)
    errors << message
  elsif message.is_a?(Enumerable)
    message.each do |error_message|
      errors << error_message
    end
  else
    errors << message
  end
end

#[](index) ⇒ Object



11
12
13
# File 'lib/harbor/errors.rb', line 11

def [](index)
  errors[index]
end

#eachObject



27
28
29
30
31
# File 'lib/harbor/errors.rb', line 27

def each
  errors.each do |error|
    yield error
  end
end

#sizeObject



33
34
35
# File 'lib/harbor/errors.rb', line 33

def size
  errors.size
end