Class: RBI::Type::Proc
- Extended by:
- T::Sig
- Defined in:
- lib/rbi/type.rb
Overview
A proc type like ‘T.proc.void`.
Instance Attribute Summary collapse
- 
  
    
      #proc_bind  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute proc_bind. 
- 
  
    
      #proc_params  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute proc_params. 
- 
  
    
      #proc_returns  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute proc_returns. 
Instance Method Summary collapse
- #==(other) ⇒ Object
- #bind(type) ⇒ Object
- 
  
    
      #initialize  ⇒ Proc 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Proc. 
- #params(**params) ⇒ Object
- #returns(type) ⇒ Object
- #to_rbi ⇒ Object
- #void ⇒ Object
Methods inherited from RBI::Type
all, any, anything, attached_class, boolean, class_of, #eql?, generic, #hash, #nilable, nilable, #nilable?, #non_nilable, noreturn, parse_node, parse_string, proc, #rbs_string, self_type, shape, simple, t_class, #to_s, tuple, type_parameter, untyped, void
Constructor Details
Instance Attribute Details
#proc_bind ⇒ Object (readonly)
Returns the value of attribute proc_bind.
| 397 398 399 | # File 'lib/rbi/type.rb', line 397 def proc_bind @proc_bind end | 
#proc_params ⇒ Object (readonly)
Returns the value of attribute proc_params.
| 391 392 393 | # File 'lib/rbi/type.rb', line 391 def proc_params @proc_params end | 
#proc_returns ⇒ Object (readonly)
Returns the value of attribute proc_returns.
| 394 395 396 | # File 'lib/rbi/type.rb', line 394 def proc_returns @proc_returns end | 
Instance Method Details
#==(other) ⇒ Object
| 408 409 410 411 412 413 414 415 | # File 'lib/rbi/type.rb', line 408 def ==(other) return false unless Proc === other return false unless @proc_params == other.proc_params return false unless @proc_returns == other.proc_returns return false unless @proc_bind == other.proc_bind true end | 
#bind(type) ⇒ Object
| 436 437 438 439 | # File 'lib/rbi/type.rb', line 436 def bind(type) @proc_bind = type self end | 
#params(**params) ⇒ Object
| 418 419 420 421 | # File 'lib/rbi/type.rb', line 418 def params(**params) @proc_params = params self end | 
#returns(type) ⇒ Object
| 424 425 426 427 | # File 'lib/rbi/type.rb', line 424 def returns(type) @proc_returns = type self end | 
#to_rbi ⇒ Object
| 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 | # File 'lib/rbi/type.rb', line 442 def to_rbi rbi = +"T.proc" if @proc_bind rbi << ".bind(#{@proc_bind})" end unless @proc_params.empty? rbi << ".params(" rbi << @proc_params.map { |name, type| "#{name}: #{type.to_rbi}" }.join(", ") rbi << ")" end rbi << case @proc_returns when Void ".void" else ".returns(#{@proc_returns})" end rbi end |