Class: RBI::Struct
- Extended by:
- T::Sig
- Defined in:
- lib/rbi/model.rb,
lib/rbi/rewriters/merge_trees.rb
Instance Attribute Summary collapse
-
#keyword_init ⇒ Object
Returns the value of attribute keyword_init.
-
#members ⇒ Object
Returns the value of attribute members.
-
#name ⇒ Object
Returns the value of attribute name.
Attributes inherited from Tree
Attributes inherited from NodeWithComments
Attributes inherited from Node
Instance Method Summary collapse
- #compatible_with?(other) ⇒ Boolean
- #fully_qualified_name ⇒ Object
-
#initialize(name, members: [], keyword_init: false, loc: nil, comments: [], &block) ⇒ Struct
constructor
A new instance of Struct.
Methods inherited from Scope
Methods included from Indexable
Methods inherited from Tree
#<<, #add_sig_templates!, #annotate!, #deannotate!, #empty?, #filter_versions!, #flatten_singleton_methods!, #flatten_visibilities!, #group_nodes!, #index, #merge, #nest_non_public_members!, #nest_singleton_methods!, #nest_top_level_members!, #replace_attributes_with_methods!, #sort_nodes!
Methods inherited from NodeWithComments
#annotations, #merge_with, #version_requirements
Methods inherited from Node
#detach, #merge_with, #parent_conflict_tree, #parent_scope, #print, #rbs_print, #rbs_string, #replace, #satisfies_version?, #string
Constructor Details
#initialize(name, members: [], keyword_init: false, loc: nil, comments: [], &block) ⇒ Struct
Returns a new instance of Struct.
296 297 298 299 300 301 302 |
# File 'lib/rbi/model.rb', line 296 def initialize(name, members: [], keyword_init: false, loc: nil, comments: [], &block) super(loc: loc, comments: comments) {} @name = name @members = members @keyword_init = keyword_init block&.call(self) end |
Instance Attribute Details
#keyword_init ⇒ Object
Returns the value of attribute keyword_init.
284 285 286 |
# File 'lib/rbi/model.rb', line 284 def keyword_init @keyword_init end |
#members ⇒ Object
Returns the value of attribute members.
281 282 283 |
# File 'lib/rbi/model.rb', line 281 def members @members end |
#name ⇒ Object
Returns the value of attribute name.
278 279 280 |
# File 'lib/rbi/model.rb', line 278 def name @name end |
Instance Method Details
#compatible_with?(other) ⇒ Boolean
402 403 404 |
# File 'lib/rbi/rewriters/merge_trees.rb', line 402 def compatible_with?(other) other.is_a?(Struct) && members == other.members && keyword_init == other.keyword_init end |
#fully_qualified_name ⇒ Object
305 306 307 308 309 |
# File 'lib/rbi/model.rb', line 305 def fully_qualified_name return name if name.start_with?("::") "#{parent_scope&.fully_qualified_name}::#{name}" end |