Class: RBI::Type::Proc
- Inherits:
-
Type
- Object
- Type
- RBI::Type::Proc
- Defined in:
- lib/rbi/type.rb
Overview
A proc type like T.proc.void.
Instance Attribute Summary collapse
- #proc_bind ⇒ Object readonly
- #proc_params ⇒ Object readonly
- #proc_returns ⇒ Object readonly
Instance Method Summary collapse
- #==(other) ⇒ Object
- #bind(type) ⇒ Object
-
#initialize ⇒ Proc
constructor
A new instance of Proc.
- #normalize ⇒ Object
- #params(**params) ⇒ Object
- #returns(type) ⇒ Object
- #simplify ⇒ Object
- #to_rbi ⇒ Object
- #void ⇒ Object
Constructor Details
Instance Attribute Details
#proc_bind ⇒ Object (readonly)
758 759 760 |
# File 'lib/rbi/type.rb', line 758 def proc_bind @proc_bind end |
#proc_params ⇒ Object (readonly)
752 753 754 |
# File 'lib/rbi/type.rb', line 752 def proc_params @proc_params end |
#proc_returns ⇒ Object (readonly)
755 756 757 |
# File 'lib/rbi/type.rb', line 755 def proc_returns @proc_returns end |
Instance Method Details
#==(other) ⇒ Object
770 771 772 773 774 775 776 777 |
# File 'lib/rbi/type.rb', line 770 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
798 799 800 801 |
# File 'lib/rbi/type.rb', line 798 def bind(type) @proc_bind = type self end |
#normalize ⇒ Object
830 831 832 |
# File 'lib/rbi/type.rb', line 830 def normalize self end |
#params(**params) ⇒ Object
780 781 782 783 |
# File 'lib/rbi/type.rb', line 780 def params(**params) @proc_params = params self end |
#returns(type) ⇒ Object
786 787 788 789 |
# File 'lib/rbi/type.rb', line 786 def returns(type) @proc_returns = type self end |
#simplify ⇒ Object
836 837 838 |
# File 'lib/rbi/type.rb', line 836 def simplify self end |
#to_rbi ⇒ Object
805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 |
# File 'lib/rbi/type.rb', line 805 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 |