Class: Usman::ErrorHash
- Inherits:
-
Object
- Object
- Usman::ErrorHash
- Defined in:
- lib/usman/extras/import_error_handler.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#warnings ⇒ Object
Returns the value of attribute warnings.
Instance Method Summary collapse
- #errors? ⇒ Boolean
-
#initialize ⇒ ErrorHash
constructor
A new instance of ErrorHash.
- #print_all ⇒ Object
- #print_dot ⇒ Object
- #warnings? ⇒ Boolean
Constructor Details
#initialize ⇒ ErrorHash
Returns a new instance of ErrorHash.
9 10 11 12 |
# File 'lib/usman/extras/import_error_handler.rb', line 9 def initialize @warnings = [] @errors = [] end |
Instance Attribute Details
#errors ⇒ Object
Returns the value of attribute errors.
6 7 8 |
# File 'lib/usman/extras/import_error_handler.rb', line 6 def errors @errors end |
#warnings ⇒ Object
Returns the value of attribute warnings.
6 7 8 |
# File 'lib/usman/extras/import_error_handler.rb', line 6 def warnings @warnings end |
Instance Method Details
#errors? ⇒ Boolean
18 19 20 |
# File 'lib/usman/extras/import_error_handler.rb', line 18 def errors? @errors.any? end |
#print_all ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/usman/extras/import_error_handler.rb', line 32 def print_all self.warnings.each do |item| puts "Summary: #{item[:summary]}".yellow puts "Details: #{item[:details]}".yellow if item[:details] puts "Stack Trace: #{item[:stack_trace]}".yellow if item[:stack_trace] puts "" end self.errors.each do |item| puts "Summary: #{item[:summary]}".red puts "Details: #{item[:details]}".red if item[:details] puts "Stack Trace: #{item[:stack_trace]}".red if item[:stack_trace] puts "" end end |
#print_dot ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/usman/extras/import_error_handler.rb', line 22 def print_dot if self.warnings? print ".".yellow elsif self.errors? print ".".red else print ".".green end end |
#warnings? ⇒ Boolean
14 15 16 |
# File 'lib/usman/extras/import_error_handler.rb', line 14 def warnings? @warnings.any? end |