Class: RBS::Types::UntypedFunction
- Inherits:
-
Object
- Object
- RBS::Types::UntypedFunction
- Defined in:
- lib/rbs/types.rb
Instance Attribute Summary collapse
-
#return_type ⇒ Object
readonly
Returns the value of attribute return_type.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #each_param(&block) ⇒ Object
- #each_type(&block) ⇒ Object
- #empty? ⇒ Boolean
- #free_variables(acc = Set.new) ⇒ Object
- #has_classish_type? ⇒ Boolean
- #has_self_type? ⇒ Boolean
- #hash ⇒ Object
-
#initialize(return_type:) ⇒ UntypedFunction
constructor
A new instance of UntypedFunction.
- #map_type(&block) ⇒ Object
- #map_type_name(&block) ⇒ Object
- #param_to_s ⇒ Object
- #return_to_s ⇒ Object
- #sub(subst) ⇒ Object
- #to_json(state = nil) ⇒ Object
- #update(return_type: self.return_type) ⇒ Object
- #with_nonreturn_void? ⇒ Boolean
- #with_return_type(ty) ⇒ Object
Constructor Details
#initialize(return_type:) ⇒ UntypedFunction
Returns a new instance of UntypedFunction.
1254 1255 1256 |
# File 'lib/rbs/types.rb', line 1254 def initialize(return_type:) @return_type = return_type end |
Instance Attribute Details
#return_type ⇒ Object (readonly)
Returns the value of attribute return_type.
1252 1253 1254 |
# File 'lib/rbs/types.rb', line 1252 def return_type @return_type end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
1336 1337 1338 |
# File 'lib/rbs/types.rb', line 1336 def ==(other) other.is_a?(UntypedFunction) && other.return_type == return_type end |
#each_param(&block) ⇒ Object
1284 1285 1286 1287 1288 1289 1290 |
# File 'lib/rbs/types.rb', line 1284 def each_param(&block) if block # noop else enum_for :each_param end end |
#each_type(&block) ⇒ Object
1276 1277 1278 1279 1280 1281 1282 |
# File 'lib/rbs/types.rb', line 1276 def each_type(&block) if block yield return_type else enum_for :each_type end end |
#empty? ⇒ Boolean
1312 1313 1314 |
# File 'lib/rbs/types.rb', line 1312 def empty? true end |
#free_variables(acc = Set.new) ⇒ Object
1258 1259 1260 |
# File 'lib/rbs/types.rb', line 1258 def free_variables(acc = Set.new) return_type.free_variables(acc) end |
#has_classish_type? ⇒ Boolean
1320 1321 1322 |
# File 'lib/rbs/types.rb', line 1320 def has_classish_type? return_type.has_classish_type? end |
#has_self_type? ⇒ Boolean
1316 1317 1318 |
# File 'lib/rbs/types.rb', line 1316 def has_self_type? return_type.has_self_type? end |
#hash ⇒ Object
1342 1343 1344 |
# File 'lib/rbs/types.rb', line 1342 def hash self.class.hash ^ return_type.hash end |
#map_type(&block) ⇒ Object
1262 1263 1264 1265 1266 1267 1268 |
# File 'lib/rbs/types.rb', line 1262 def map_type(&block) if block update(return_type: yield(return_type)) else enum_for :map_type end end |
#map_type_name(&block) ⇒ Object
1270 1271 1272 1273 1274 |
# File 'lib/rbs/types.rb', line 1270 def map_type_name(&block) UntypedFunction.new( return_type: return_type.map_type_name(&block) ) end |
#param_to_s ⇒ Object
1328 1329 1330 |
# File 'lib/rbs/types.rb', line 1328 def param_to_s "?" end |
#return_to_s ⇒ Object
1332 1333 1334 |
# File 'lib/rbs/types.rb', line 1332 def return_to_s return_type.to_s(1) end |
#sub(subst) ⇒ Object
1298 1299 1300 1301 1302 |
# File 'lib/rbs/types.rb', line 1298 def sub(subst) return self if subst.empty? map_type { _1.sub(subst) } end |
#to_json(state = nil) ⇒ Object
1292 1293 1294 1295 1296 |
# File 'lib/rbs/types.rb', line 1292 def to_json(state = nil) { return_type: return_type }.to_json(state) end |
#update(return_type: self.return_type) ⇒ Object
1308 1309 1310 |
# File 'lib/rbs/types.rb', line 1308 def update(return_type: self.return_type) UntypedFunction.new(return_type: return_type) end |
#with_nonreturn_void? ⇒ Boolean
1324 1325 1326 |
# File 'lib/rbs/types.rb', line 1324 def with_nonreturn_void? false end |
#with_return_type(ty) ⇒ Object
1304 1305 1306 |
# File 'lib/rbs/types.rb', line 1304 def with_return_type(ty) update(return_type: ty) end |