Class: RBS::Definition::InstanceAncestors
- Inherits:
-
Object
- Object
- RBS::Definition::InstanceAncestors
- Defined in:
- lib/rbs/definition.rb
Instance Attribute Summary collapse
-
#ancestors ⇒ Object
readonly
Returns the value of attribute ancestors.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#type_name ⇒ Object
readonly
Returns the value of attribute type_name.
Instance Method Summary collapse
- #apply(args, location:) ⇒ Object
-
#initialize(type_name:, params:, ancestors:) ⇒ InstanceAncestors
constructor
A new instance of InstanceAncestors.
Constructor Details
#initialize(type_name:, params:, ancestors:) ⇒ InstanceAncestors
Returns a new instance of InstanceAncestors.
144 145 146 147 148 |
# File 'lib/rbs/definition.rb', line 144 def initialize(type_name:, params:, ancestors:) @type_name = type_name @params = params @ancestors = ancestors end |
Instance Attribute Details
#ancestors ⇒ Object (readonly)
Returns the value of attribute ancestors.
142 143 144 |
# File 'lib/rbs/definition.rb', line 142 def ancestors @ancestors end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
141 142 143 |
# File 'lib/rbs/definition.rb', line 141 def params @params end |
#type_name ⇒ Object (readonly)
Returns the value of attribute type_name.
140 141 142 |
# File 'lib/rbs/definition.rb', line 140 def type_name @type_name end |
Instance Method Details
#apply(args, location:) ⇒ Object
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/rbs/definition.rb', line 150 def apply(args, location:) InvalidTypeApplicationError.check!( type_name: type_name, args: args, params: params, location: location ) subst = Substitution.build(params, args) ancestors.map do |ancestor| case ancestor when Ancestor::Instance if ancestor.args.empty? ancestor else Ancestor::Instance.new( name: ancestor.name, args: ancestor.args.map {|type| type.sub(subst) } ) end when Ancestor::Singleton ancestor end end end |