Class: RBI::Attr
- Inherits:
-
NodeWithComments
- Object
- Node
- NodeWithComments
- RBI::Attr
- Extended by:
- T::Helpers, T::Sig
- Includes:
- Indexable
- Defined in:
- lib/rbi/model.rb,
lib/rbi/index.rb,
lib/rbi/rewriters/merge_trees.rb,
lib/rbi/rewriters/attr_to_methods.rb
Overview
Attributes
Direct Known Subclasses
Instance Attribute Summary collapse
-
#names ⇒ Object
readonly
Returns the value of attribute names.
-
#sigs ⇒ Object
readonly
Returns the value of attribute sigs.
-
#visibility ⇒ Object
Returns the value of attribute visibility.
Attributes inherited from NodeWithComments
Attributes inherited from Node
Instance Method Summary collapse
- #compatible_with?(other) ⇒ Boolean
- #convert_to_methods ⇒ Object
- #fully_qualified_names ⇒ Object
- #index_ids ⇒ Object
-
#initialize(name, names, visibility: Public.new, sigs: [], loc: nil, comments: []) ⇒ Attr
constructor
A new instance of Attr.
- #merge_with(other) ⇒ Object
Methods inherited from NodeWithComments
#annotations, #version_requirements
Methods inherited from Node
#detach, #parent_conflict_tree, #parent_scope, #print, #rbs_print, #rbs_string, #replace, #satisfies_version?, #string
Constructor Details
#initialize(name, names, visibility: Public.new, sigs: [], loc: nil, comments: []) ⇒ Attr
Returns a new instance of Attr.
376 377 378 379 380 381 |
# File 'lib/rbi/model.rb', line 376 def initialize(name, names, visibility: Public.new, sigs: [], loc: nil, comments: []) super(loc: loc, comments: comments) @names = T.let([name, *names], T::Array[Symbol]) @visibility = visibility @sigs = sigs end |
Instance Attribute Details
#names ⇒ Object (readonly)
Returns the value of attribute names.
358 359 360 |
# File 'lib/rbi/model.rb', line 358 def names @names end |
#sigs ⇒ Object (readonly)
Returns the value of attribute sigs.
364 365 366 |
# File 'lib/rbi/model.rb', line 364 def sigs @sigs end |
#visibility ⇒ Object
Returns the value of attribute visibility.
361 362 363 |
# File 'lib/rbi/model.rb', line 361 def visibility @visibility end |
Instance Method Details
#compatible_with?(other) ⇒ Boolean
420 421 422 423 424 425 |
# File 'lib/rbi/rewriters/merge_trees.rb', line 420 def compatible_with?(other) return false unless other.is_a?(Attr) return false unless names == other.names sigs.empty? || other.sigs.empty? || sigs == other.sigs end |
#convert_to_methods ⇒ Object
61 |
# File 'lib/rbi/rewriters/attr_to_methods.rb', line 61 def convert_to_methods; end |
#fully_qualified_names ⇒ Object
384 |
# File 'lib/rbi/model.rb', line 384 def fully_qualified_names; end |
#index_ids ⇒ Object
113 114 115 |
# File 'lib/rbi/index.rb', line 113 def index_ids fully_qualified_names end |
#merge_with(other) ⇒ Object
428 429 430 431 432 433 434 435 |
# File 'lib/rbi/rewriters/merge_trees.rb', line 428 def merge_with(other) return unless other.is_a?(Attr) super other.sigs.each do |sig| sigs << sig unless sigs.include?(sig) end end |