Class: Sus::RespondTo::WithOptions
- Inherits:
-
Object
- Object
- Sus::RespondTo::WithOptions
- Defined in:
- lib/sus/respond_to.rb
Overview
Represents a constraint on method keyword options.
Instance Method Summary collapse
-
#call(assertions, subject) ⇒ Object
Evaluate this constraint against method parameters.
-
#initialize(options) ⇒ WithOptions
constructor
Initialize a new WithOptions constraint.
-
#print(output) ⇒ Object
Print a representation of this constraint.
Constructor Details
#initialize(options) ⇒ WithOptions
Initialize a new WithOptions constraint.
45 46 47 |
# File 'lib/sus/respond_to.rb', line 45 def initialize() @options = end |
Instance Method Details
#call(assertions, subject) ⇒ Object
Evaluate this constraint against method parameters.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/sus/respond_to.rb', line 58 def call(assertions, subject) = {} @options.each{|name| [name] = nil} subject.each do |type, name| [name] = type end assertions.nested(self) do |assertions| .each do |name, type| assertions.assert(type != nil, "option #{name}: is required") end end end |
#print(output) ⇒ Object
Print a representation of this constraint.
51 52 53 |
# File 'lib/sus/respond_to.rb', line 51 def print(output) output.write("with options ", :variable, @options.inspect) end |