Class: RBS::Types::Proc
- Inherits:
-
Object
- Object
- RBS::Types::Proc
- Defined in:
- lib/rbs/types.rb
Instance Attribute Summary collapse
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #each_type(&block) ⇒ Object
- #free_variables(set = ) ⇒ Object
- #hash ⇒ Object
-
#initialize(location:, type:) ⇒ Proc
constructor
A new instance of Proc.
- #map_type_name(&block) ⇒ Object
- #sub(s) ⇒ Object
- #to_json(*a) ⇒ Object
- #to_s(level = 0) ⇒ Object
Constructor Details
#initialize(location:, type:) ⇒ Proc
Returns a new instance of Proc.
954 955 956 957 |
# File 'lib/rbs/types.rb', line 954 def initialize(location:, type:) @type = type @location = location end |
Instance Attribute Details
#location ⇒ Object (readonly)
Returns the value of attribute location.
952 953 954 |
# File 'lib/rbs/types.rb', line 952 def location @location end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
951 952 953 |
# File 'lib/rbs/types.rb', line 951 def type @type end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
959 960 961 |
# File 'lib/rbs/types.rb', line 959 def ==(other) other.is_a?(Proc) && other.type == type end |
#each_type(&block) ⇒ Object
985 986 987 988 989 990 991 |
# File 'lib/rbs/types.rb', line 985 def each_type(&block) if block type.each_type(&block) else enum_for :each_type end end |
#free_variables(set = ) ⇒ Object
969 970 971 |
# File 'lib/rbs/types.rb', line 969 def free_variables(set = Set[]) type.free_variables(set) end |
#hash ⇒ Object
965 966 967 |
# File 'lib/rbs/types.rb', line 965 def hash self.class.hash ^ type.hash end |
#map_type_name(&block) ⇒ Object
993 994 995 996 997 998 |
# File 'lib/rbs/types.rb', line 993 def map_type_name(&block) Proc.new( type: type.map_type_name(&block), location: location ) end |
#sub(s) ⇒ Object
977 978 979 |
# File 'lib/rbs/types.rb', line 977 def sub(s) self.class.new(type: type.sub(s), location: location) end |
#to_json(*a) ⇒ Object
973 974 975 |
# File 'lib/rbs/types.rb', line 973 def to_json(*a) { class: :proc, type: type, location: location }.to_json(*a) end |
#to_s(level = 0) ⇒ Object
981 982 983 |
# File 'lib/rbs/types.rb', line 981 def to_s(level = 0) "^(#{type.param_to_s}) -> #{type.return_to_s}".lstrip end |