Class: SoberSwag::Reporting::Report::List

Inherits:
Base
  • Object
show all
Defined in:
lib/sober_swag/reporting/report/list.rb

Overview

Report errors that arose while parsing a list.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#full_errors, #path_hash

Constructor Details

#initialize(elements) ⇒ List

Returns a new instance of List.

Parameters:

  • element (Hash<Int, Base>)

    a hash of bad element indices to bad element values



10
11
12
# File 'lib/sober_swag/reporting/report/list.rb', line 10

def initialize(elements)
  @elements = elements
end

Instance Attribute Details

#elementsObject (readonly)

Returns the value of attribute elements.



14
15
16
# File 'lib/sober_swag/reporting/report/list.rb', line 14

def elements
  @elements
end

Instance Method Details

#each_errorObject



16
17
18
19
20
21
22
23
24
# File 'lib/sober_swag/reporting/report/list.rb', line 16

def each_error
  return enum_for(:each_error) unless block_given?

  elements.each do |k, v|
    v.each_error do |nested, err|
      yield ["[#{k}]", nested].reject(&:nil?).join(''), err
    end
  end
end