Class: Contracts::Builtin::Args

Inherits:
CallableClass show all
Defined in:
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

Instance Method Summary collapse

Methods inherited from CallableClass

[]

Constructor Details

#initialize(contract) ⇒ Args

Returns a new instance of Args.



347
348
349
350
# File 'lib/contracts/builtin_contracts.rb', line 347

def initialize(contract)
  super()
  @contract = contract
end

Instance Attribute Details

#contractObject (readonly)

Returns the value of attribute contract.



345
346
347
# File 'lib/contracts/builtin_contracts.rb', line 345

def contract
  @contract
end

Instance Method Details

#to_sObject



352
353
354
# File 'lib/contracts/builtin_contracts.rb', line 352

def to_s
  "Args[#{@contract}]"
end