Class: RBS::Types::Alias
- Inherits:
-
Object
- Object
- RBS::Types::Alias
- Includes:
- Application, _TypeBase
- Defined in:
- lib/rbs/types.rb,
sig/types.rbs
Instance Attribute Summary collapse
-
#location ⇒ loc?
readonly
Returns the value of attribute location.
Attributes included from Application
Instance Method Summary collapse
-
#initialize(name:, args:, location:) ⇒ Alias
constructor
A new instance of Alias.
- #map_type {|arg0| ... } ⇒ Object
- #map_type_name(&block) ⇒ Object
- #sub(s) ⇒ Object
- #to_json(state = nil) ⇒ Object
Methods included from Application
#==, #each_type, #free_variables, #has_classish_type?, #has_self_type?, #hash, #to_s, #with_nonreturn_void?
Methods included from _TypeBase
#each_type, #free_variables, #has_classish_type?, #has_self_type?, #to_s, #with_nonreturn_void?
Constructor Details
#initialize(name:, args:, location:) ⇒ Alias
Returns a new instance of Alias.
415 416 417 418 419 |
# File 'lib/rbs/types.rb', line 415 def initialize(name:, args:, location:) @name = name @args = args @location = location end |
Instance Attribute Details
#location ⇒ loc? (readonly)
Returns the value of attribute location.
411 412 413 |
# File 'lib/rbs/types.rb', line 411 def location @location end |
Instance Method Details
#map_type ⇒ Alias #map_type ⇒ Enumerator[t, Alias]
439 440 441 442 443 444 445 446 447 448 449 |
# File 'lib/rbs/types.rb', line 439 def map_type(&block) if block Alias.new( name: name, args: args.map {|type| yield type }, location: location ) else enum_for :map_type end end |
#map_type_name(&block) ⇒ Object
431 432 433 434 435 436 437 |
# File 'lib/rbs/types.rb', line 431 def map_type_name(&block) Alias.new( name: yield(name, location, self), args: args.map {|arg| arg.map_type_name(&block) }, location: location ) end |
#sub(s) ⇒ Object
425 426 427 428 429 |
# File 'lib/rbs/types.rb', line 425 def sub(s) return self if s.empty? Alias.new(name: name, args: args.map {|ty| ty.sub(s) }, location: location) end |
#to_json(state = nil) ⇒ Object
421 422 423 |
# File 'lib/rbs/types.rb', line 421 def to_json(state = nil) { class: :alias, name: name, args: args, location: location }.to_json(state) end |