Class: RBI::Attr Abstract
- Inherits:
-
NodeWithComments
- Object
- Node
- NodeWithComments
- RBI::Attr
- 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
This class is abstract.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#names ⇒ Object
readonly
: Array.
-
#sigs ⇒ Object
readonly
: Array.
-
#visibility ⇒ Object
: Visibility.
Attributes inherited from NodeWithComments
Attributes inherited from Node
Instance Method Summary collapse
-
#compatible_with?(other) ⇒ Boolean
: (Node other) -> bool.
-
#convert_to_methods ⇒ Object
abstract
: -> Array.
-
#fully_qualified_names ⇒ Object
abstract
: -> Array.
-
#index_ids ⇒ Object
: -> Array.
- #initialize(name, names, visibility: Public.new, sigs: [], loc: nil, comments: []) ⇒ Attr constructor
-
#merge_with(other) ⇒ Object
: (Node other) -> void.
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
316 317 318 319 320 321 |
# File 'lib/rbi/model.rb', line 316 def initialize(name, names, visibility: Public.new, sigs: [], loc: nil, comments: []) super(loc: loc, comments: comments) @names = [name, *names] #: Array[Symbol] @visibility = visibility @sigs = sigs end |
Instance Attribute Details
#names ⇒ Object (readonly)
: Array
300 301 302 |
# File 'lib/rbi/model.rb', line 300 def names @names end |
#sigs ⇒ Object (readonly)
: Array
306 307 308 |
# File 'lib/rbi/model.rb', line 306 def sigs @sigs end |
#visibility ⇒ Object
: Visibility
303 304 305 |
# File 'lib/rbi/model.rb', line 303 def visibility @visibility end |
Instance Method Details
#compatible_with?(other) ⇒ Boolean
: (Node other) -> bool
407 408 409 410 411 412 |
# File 'lib/rbi/rewriters/merge_trees.rb', line 407 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
This method is abstract.
: -> Array
59 |
# File 'lib/rbi/rewriters/attr_to_methods.rb', line 59 def convert_to_methods = raise NotImplementedError, "Abstract method called" |
#fully_qualified_names ⇒ Object
This method is abstract.
: -> Array
325 |
# File 'lib/rbi/model.rb', line 325 def fully_qualified_names = raise NotImplementedError, "Abstract method called" |
#index_ids ⇒ Object
: -> Array
104 105 106 |
# File 'lib/rbi/index.rb', line 104 def index_ids fully_qualified_names end |
#merge_with(other) ⇒ Object
: (Node other) -> void
416 417 418 419 420 421 422 423 |
# File 'lib/rbi/rewriters/merge_trees.rb', line 416 def merge_with(other) return unless other.is_a?(Attr) super other.sigs.each do |sig| sigs << sig unless sigs.include?(sig) end end |