Class: Jschematic::Errors
- Inherits:
-
Object
- Object
- Jschematic::Errors
- Includes:
- Enumerable
- Defined in:
- lib/jschematic/errors.rb
Instance Method Summary collapse
- #add(id, desc) ⇒ Object
- #all ⇒ Object
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(raise_on_error = false) ⇒ Errors
constructor
A new instance of Errors.
- #reset! ⇒ Object
Constructor Details
#initialize(raise_on_error = false) ⇒ Errors
Returns a new instance of Errors.
5 6 7 8 |
# File 'lib/jschematic/errors.rb', line 5 def initialize(raise_on_error = false) @raise_on_error = raise_on_error @errors = [] end |
Instance Method Details
#add(id, desc) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/jschematic/errors.rb', line 10 def add(id, desc) if @raise_on_error raise "Error: #{desc}" else @errors << [id, desc] end end |
#all ⇒ Object
18 19 20 |
# File 'lib/jschematic/errors.rb', line 18 def all @errors end |
#each(&block) ⇒ Object
30 31 32 |
# File 'lib/jschematic/errors.rb', line 30 def each(&block) @errors.each(&block) end |
#empty? ⇒ Boolean
22 23 24 |
# File 'lib/jschematic/errors.rb', line 22 def empty? @errors.empty? end |
#reset! ⇒ Object
26 27 28 |
# File 'lib/jschematic/errors.rb', line 26 def reset! @errors = [] end |