Class: SoberSwag::Reporting::Report::Value

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

Overview

Report for a single value. Basically a wrapper around an array of strings.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#full_errors, #path_hash

Constructor Details

#initialize(problems) ⇒ Value

Returns a new instance of Value.

Parameters:

  • problems (Array<String>)

    problems with it

Raises:

  • (ArgumentError)


10
11
12
13
14
# File 'lib/sober_swag/reporting/report/value.rb', line 10

def initialize(problems)
  raise ArgumentError, "#{problems} was not an enum" unless problems.respond_to?(:each)

  @problems = problems
end

Instance Attribute Details

#problemsArray<String> (readonly)

Returns the problems the value had.

Returns:

  • (Array<String>)

    the problems the value had



18
19
20
# File 'lib/sober_swag/reporting/report/value.rb', line 18

def problems
  @problems
end

Instance Method Details

#each_errorObject



20
21
22
23
24
25
26
# File 'lib/sober_swag/reporting/report/value.rb', line 20

def each_error
  return enum_for(:each_error) unless block_given?

  problems.each do |problem|
    yield nil, problem
  end
end