Class: Contracts::Postcondition
- Defined in:
- lib/ruby_contracts/postcondition.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
- #after? ⇒ Boolean
- #before? ⇒ Boolean
-
#initialize(message, block) ⇒ Postcondition
constructor
A new instance of Postcondition.
- #satisfied?(context, arguments, result = nil) ⇒ Boolean
Constructor Details
#initialize(message, block) ⇒ Postcondition
Returns a new instance of Postcondition.
5 6 7 8 |
# File 'lib/ruby_contracts/postcondition.rb', line 5 def initialize(, block) @message = "invalid postcondition: #{ || 'no message given'}" @block = block end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
3 4 5 |
# File 'lib/ruby_contracts/postcondition.rb', line 3 def @message end |
Instance Method Details
#after? ⇒ Boolean
18 19 20 |
# File 'lib/ruby_contracts/postcondition.rb', line 18 def after? true end |
#before? ⇒ Boolean
14 15 16 |
# File 'lib/ruby_contracts/postcondition.rb', line 14 def before? false end |
#satisfied?(context, arguments, result = nil) ⇒ Boolean
10 11 12 |
# File 'lib/ruby_contracts/postcondition.rb', line 10 def satisfied?(context, arguments, result=nil) context.instance_exec(result, *arguments, &@block) end |