Class: Ibex::Verify::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/ibex/verify/result.rb

Overview

Immutable independent-verification report.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(algorithm:, strict:, checks:, violations:, bounds:) ⇒ Result

Returns a new instance of Result.



40
41
42
43
44
45
46
47
# File 'lib/ibex/verify/result.rb', line 40

def initialize(algorithm:, strict:, checks:, violations:, bounds:)
  @algorithm = algorithm.freeze
  @strict = strict
  @checks = checks.dup.freeze
  @violations = violations.dup.freeze
  @bounds = bounds.dup.freeze
  freeze
end

Instance Attribute Details

#algorithmObject (readonly)

@rbs! type report_value = String | Integer | bool | Array | Hash[Symbol, Integer] | Array[Hash[Symbol, String]]



32
33
34
# File 'lib/ibex/verify/result.rb', line 32

def algorithm
  @algorithm
end

#boundsObject (readonly)

: Hash[Symbol, Integer]



36
37
38
# File 'lib/ibex/verify/result.rb', line 36

def bounds
  @bounds
end

#checksObject (readonly)

: Array



34
35
36
# File 'lib/ibex/verify/result.rb', line 34

def checks
  @checks
end

#strictObject (readonly)

: bool



33
34
35
# File 'lib/ibex/verify/result.rb', line 33

def strict
  @strict
end

#violationsObject (readonly)

: Array



35
36
37
# File 'lib/ibex/verify/result.rb', line 35

def violations
  @violations
end

Instance Method Details

#to_hObject



53
54
55
56
57
58
59
60
# File 'lib/ibex/verify/result.rb', line 53

def to_h
  {
    ibex_report: "verify", schema_version: 1, algorithm: @algorithm,
    strict: @strict, checks: @checks, bounds: @bounds,
    result: valid? ? "valid" : "invalid",
    violations: @violations.map(&:to_h)
  }.freeze
end

#valid?Boolean

Returns:

  • (Boolean)


50
# File 'lib/ibex/verify/result.rb', line 50

def valid? = @violations.empty?