Class: Contracts::Builtin::And
- Inherits:
-
CallableClass
- Object
- CallableClass
- Contracts::Builtin::And
- Defined in:
- lib/contracts/builtin_contracts.rb
Overview
Takes a variable number of contracts. The contract passes if all contracts pass. Example: And[Integer, Float]
Instance Method Summary collapse
-
#initialize(*vals) ⇒ And
constructor
A new instance of And.
- #to_s ⇒ Object
- #valid?(val) ⇒ Boolean
Methods inherited from CallableClass
Constructor Details
#initialize(*vals) ⇒ And
Returns a new instance of And.
151 152 153 154 |
# File 'lib/contracts/builtin_contracts.rb', line 151 def initialize(*vals) super() @vals = vals end |
Instance Method Details
#to_s ⇒ Object
163 164 165 166 167 168 169 |
# File 'lib/contracts/builtin_contracts.rb', line 163 def to_s # rubocop:disable Style/StringConcatenation @vals[0, @vals.size-1].map do |x| InspectWrapper.create(x) end.join(", ") + " and " + InspectWrapper.create(@vals[-1]).to_s # rubocop:enable Style/StringConcatenation end |