Class: ObjWithInvariants

Inherits:
Object
  • Object
show all
Includes:
Contracts, Contracts::Invariants
Defined in:
lib/contracts-ruby2/benchmarks/invariants.rb,
lib/contracts-ruby3/benchmarks/invariants.rb

Constant Summary

Constants included from Contracts

Contracts::VERSION

Constants included from Contracts::Builtin

Contracts::Builtin::ArrayOf, Contracts::Builtin::SetOf

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Contracts::Invariants

common, extended, included, #verify_invariants!

Methods included from Contracts

extended, included

Methods included from Contracts::Attrs

#attr_accessor_with_contract, #attr_reader_with_contract, #attr_writer_with_contract

Constructor Details

#initialize(value) ⇒ ObjWithInvariants

Returns a new instance of ObjWithInvariants.



29
30
31
# File 'lib/contracts-ruby2/benchmarks/invariants.rb', line 29

def initialize value
  @value = value
end

Instance Attribute Details

#valueObject

Returns the value of attribute value.



28
29
30
# File 'lib/contracts-ruby2/benchmarks/invariants.rb', line 28

def value
  @value
end

Instance Method Details

#contracts_add(a, b) ⇒ Object



34
35
36
# File 'lib/contracts-ruby2/benchmarks/invariants.rb', line 34

def contracts_add a, b
  a + b
end