Class: RBI::Attr
Abstract
- Inherits:
-
NodeWithComments
show all
- 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
Instance Attribute Summary collapse
#comments
Attributes inherited from Node
#loc, #parent_tree
Instance Method Summary
collapse
#annotations, #comments?, #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::DEFAULT, sigs: nil, loc: nil, comments: nil) ⇒ Attr
Returns a new instance of Attr.
353
354
355
356
357
358
|
# File 'lib/rbi/model.rb', line 353
def initialize(name, names, visibility: Public::DEFAULT, sigs: nil, loc: nil, comments: nil)
super(loc: loc, comments: )
@names = [name, *names] @visibility = visibility
@sigs = sigs end
|
Instance Attribute Details
#names ⇒ Object
327
328
329
|
# File 'lib/rbi/model.rb', line 327
def names
@names
end
|
#sigs ⇒ Object
333
334
335
|
# File 'lib/rbi/model.rb', line 333
def sigs
@sigs ||= []
end
|
#visibility ⇒ Object
330
331
332
|
# File 'lib/rbi/model.rb', line 330
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
59
|
# File 'lib/rbi/rewriters/attr_to_methods.rb', line 59
def convert_to_methods = raise NotImplementedError, "Abstract method called"
|
#fully_qualified_names ⇒ Object
362
|
# File 'lib/rbi/model.rb', line 362
def fully_qualified_names = raise NotImplementedError, "Abstract method called"
|
#index_ids ⇒ Object
104
105
106
|
# File 'lib/rbi/index.rb', line 104
def index_ids
fully_qualified_names
end
|
#merge_with(other) ⇒ Object
429
430
431
432
433
434
435
436
|
# File 'lib/rbi/rewriters/merge_trees.rb', line 429
def merge_with(other)
return unless other.is_a?(Attr)
super
other.sigs.each do |sig|
sigs << sig unless sigs.include?(sig)
end
end
|
#sigs? ⇒ Boolean
338
339
340
|
# File 'lib/rbi/model.rb', line 338
def sigs?
!@sigs.nil? && !@sigs.empty?
end
|