Class: RDL::Contract::AndContract
- Inherits:
-
RDL::Contract
- Object
- RDL::Contract
- RDL::Contract::AndContract
- Defined in:
- lib/rdl/contracts/and.rb
Instance Attribute Summary collapse
-
#contracts ⇒ Object
readonly
Returns the value of attribute contracts.
Class Method Summary collapse
- .array_to_s(a) ⇒ Object
-
.check_array(a, slf, *v, &blk) ⇒ Object
Check an array of contracts a [:slf:] is bound to self when the contracts are checked.
Instance Method Summary collapse
-
#check(slf, *v, &blk) ⇒ Object
- :slf:
-
is bound to self when the contracts are checked.
-
#initialize(*contracts) ⇒ AndContract
constructor
A new instance of AndContract.
- #to_s ⇒ Object
Constructor Details
#initialize(*contracts) ⇒ AndContract
Returns a new instance of AndContract.
5 6 7 |
# File 'lib/rdl/contracts/and.rb', line 5 def initialize(*contracts) @contracts = contracts end |
Instance Attribute Details
#contracts ⇒ Object (readonly)
Returns the value of attribute contracts.
3 4 5 |
# File 'lib/rdl/contracts/and.rb', line 3 def contracts @contracts end |
Class Method Details
.array_to_s(a) ⇒ Object
25 26 27 |
# File 'lib/rdl/contracts/and.rb', line 25 def self.array_to_s(a) a.join(' && ') end |
.check_array(a, slf, *v, &blk) ⇒ Object
Check an array of contracts a
- :slf:
-
is bound to self when the contracts are checked
16 17 18 19 |
# File 'lib/rdl/contracts/and.rb', line 16 def self.check_array(a, slf, *v, &blk) # All contracts must be satisfied a.all? { |c| c.check(slf, *v, &blk) } end |
Instance Method Details
#check(slf, *v, &blk) ⇒ Object
- :slf:
-
is bound to self when the contracts are checked
10 11 12 |
# File 'lib/rdl/contracts/and.rb', line 10 def check(slf, *v, &blk) AndContract.check_array(@contracts, slf, *v, &blk) end |
#to_s ⇒ Object
21 22 23 |
# File 'lib/rdl/contracts/and.rb', line 21 def to_s AndContract.array_to_s(@contracts) end |