Class: Sus::Have::Value

Inherits:
Object
  • Object
show all
Defined in:
lib/sus/have.rb

Instance Method Summary collapse

Constructor Details

#initialize(predicate) ⇒ Value

Returns a new instance of Value.



52
53
54
# File 'lib/sus/have.rb', line 52

def initialize(predicate)
	@predicate = predicate
end

Instance Method Details

#call(assertions, subject) ⇒ Object



60
61
62
63
64
65
66
# File 'lib/sus/have.rb', line 60

def call(assertions, subject)
	subject.each_with_index do |value, index|
		assertions.nested("[#{index}] = #{value.inspect}") do |assertions|
			@predicate&.call(assertions, value)
		end
	end
end


56
57
58
# File 'lib/sus/have.rb', line 56

def print(output)
	output.write("value ", @predicate, :reset)
end