Class: Contracts::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.


298
299
300
# File 'lib/contracts/builtin_contracts.rb', line 298

def initialize(contract)
  @contract = contract
end

Instance Attribute Details

#contractObject (readonly)

Returns the value of attribute contract.


297
298
299
# File 'lib/contracts/builtin_contracts.rb', line 297

def contract
  @contract
end

Instance Method Details

#to_sObject


302
303
304
# File 'lib/contracts/builtin_contracts.rb', line 302

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