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.
948 949 950 951 |
# File 'lib/rbs/types.rb', line 948 def initialize(location:, type:) @type = type @location = location end |
Instance Attribute Details
#location ⇒ Object (readonly)
Returns the value of attribute location.
946 947 948 |
# File 'lib/rbs/types.rb', line 946 def location @location end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
945 946 947 |
# File 'lib/rbs/types.rb', line 945 def type @type end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
953 954 955 |
# File 'lib/rbs/types.rb', line 953 def ==(other) other.is_a?(Proc) && other.type == type end |
#each_type(&block) ⇒ Object
979 980 981 982 983 984 985 |
# File 'lib/rbs/types.rb', line 979 def each_type(&block) if block_given? type.each_type(&block) else enum_for :each_type end end |
#free_variables(set) ⇒ Object
963 964 965 |
# File 'lib/rbs/types.rb', line 963 def free_variables(set) type.free_variables(set) end |
#hash ⇒ Object
959 960 961 |
# File 'lib/rbs/types.rb', line 959 def hash self.class.hash ^ type.hash end |
#map_type_name(&block) ⇒ Object
987 988 989 990 991 992 |
# File 'lib/rbs/types.rb', line 987 def map_type_name(&block) Proc.new( type: type.map_type_name(&block), location: location ) end |
#sub(s) ⇒ Object
971 972 973 |
# File 'lib/rbs/types.rb', line 971 def sub(s) self.class.new(type: type.sub(s), location: location) end |
#to_json(*a) ⇒ Object
967 968 969 |
# File 'lib/rbs/types.rb', line 967 def to_json(*a) { class: :proc, type: type, location: location }.to_json(*a) end |
#to_s(level = 0) ⇒ Object
975 976 977 |
# File 'lib/rbs/types.rb', line 975 def to_s(level = 0) "^(#{type.param_to_s}) -> #{type.return_to_s}".lstrip end |