Class: RBI::TStructProp

Inherits:
TStructField show all
Extended by:
T::Sig
Includes:
Indexable
Defined in:
lib/rbi/index.rb,
lib/rbi/model.rb,
lib/rbi/rewriters/merge_trees.rb

Instance Attribute Summary

Attributes inherited from TStructField

#default, #name, #type

Attributes inherited from NodeWithComments

#comments

Attributes inherited from Node

#loc, #parent_tree

Instance Method Summary collapse

Methods inherited from NodeWithComments

#annotations, #merge_with, #version_requirements

Methods inherited from Node

#detach, #merge_with, #parent_conflict_tree, #parent_scope, #print, #replace, #satisfies_version?, #string

Constructor Details

#initialize(name, type, default: nil, loc: nil, comments: [], &block) ⇒ TStructProp

Returns a new instance of TStructProp.



1300
1301
1302
1303
# File 'lib/rbi/model.rb', line 1300

def initialize(name, type, default: nil, loc: nil, comments: [], &block)
  super(name, type, default: default, loc: loc, comments: comments)
  block&.call(self)
end

Instance Method Details

#compatible_with?(other) ⇒ Boolean

Returns:

  • (Boolean)


572
573
574
# File 'lib/rbi/rewriters/merge_trees.rb', line 572

def compatible_with?(other)
  other.is_a?(TStructProp) && super
end

#fully_qualified_namesObject



1306
1307
1308
1309
# File 'lib/rbi/model.rb', line 1306

def fully_qualified_names
  parent_name = parent_scope&.fully_qualified_name
  ["#{parent_name}##{name}", "#{parent_name}##{name}="]
end

#index_idsObject



213
214
215
# File 'lib/rbi/index.rb', line 213

def index_ids
  fully_qualified_names
end

#to_sObject



1312
1313
1314
# File 'lib/rbi/model.rb', line 1312

def to_s
  "#{parent_scope&.fully_qualified_name}.prop(:#{name})"
end