Class: Contracts::Builtin::Args
- Inherits:
-
CallableClass
- Object
- CallableClass
- Contracts::Builtin::Args
- Defined in:
- lib/contracts-ruby2/lib/contracts/builtin_contracts.rb,
lib/contracts-ruby3/lib/contracts/builtin_contracts.rb
Overview
Used for *args
(variadic functions). Takes a contract and uses it to validate every element passed in through *args
. Example: Args[Or[String, Num]]
Instance Attribute Summary collapse
-
#contract ⇒ Object
readonly
Returns the value of attribute contract.
Instance Method Summary collapse
-
#initialize(contract) ⇒ Args
constructor
A new instance of Args.
- #to_s ⇒ Object
Methods inherited from CallableClass
Constructor Details
#initialize(contract) ⇒ Args
Returns a new instance of Args.
327 328 329 |
# File 'lib/contracts-ruby2/lib/contracts/builtin_contracts.rb', line 327 def initialize(contract) @contract = contract end |
Instance Attribute Details
#contract ⇒ Object (readonly)
Returns the value of attribute contract.
326 327 328 |
# File 'lib/contracts-ruby2/lib/contracts/builtin_contracts.rb', line 326 def contract @contract end |
Instance Method Details
#to_s ⇒ Object
331 332 333 |
# File 'lib/contracts-ruby2/lib/contracts/builtin_contracts.rb', line 331 def to_s "Args[#{@contract}]" end |