Class: RBI::AttrWriter
- Inherits:
-
Attr
- Object
- Node
- NodeWithComments
- Attr
- RBI::AttrWriter
- Extended by:
- T::Sig
- Defined in:
- lib/rbi/model.rb,
lib/rbi/rewriters/merge_trees.rb
Instance Attribute Summary
Attributes inherited from Attr
Attributes inherited from NodeWithComments
Attributes inherited from Node
Instance Method Summary collapse
- #compatible_with?(other) ⇒ Boolean
- #fully_qualified_names ⇒ Object
-
#initialize(name, *names, visibility: Public.new, sigs: [], loc: nil, comments: [], &block) ⇒ AttrWriter
constructor
A new instance of AttrWriter.
- #to_s ⇒ Object
Methods inherited from Attr
#accept_printer, #index_ids, #merge_with, #oneline?
Methods included from Indexable
Methods inherited from NodeWithComments
#annotations, #merge_with, #oneline?
Methods inherited from Node
#accept_printer, #detach, #group_kind, #merge_with, #oneline?, #parent_conflict_tree, #parent_scope, #print, #print_blank_line_before, #replace, #string
Constructor Details
#initialize(name, *names, visibility: Public.new, sigs: [], loc: nil, comments: [], &block) ⇒ AttrWriter
Returns a new instance of AttrWriter.
455 456 457 458 |
# File 'lib/rbi/model.rb', line 455 def initialize(name, *names, visibility: Public.new, sigs: [], loc: nil, comments: [], &block) super(name, names, loc: loc, visibility: visibility, sigs: sigs, comments: comments) block&.call(self) end |
Instance Method Details
#compatible_with?(other) ⇒ Boolean
435 436 437 |
# File 'lib/rbi/rewriters/merge_trees.rb', line 435 def compatible_with?(other) other.is_a?(AttrWriter) && super end |
#fully_qualified_names ⇒ Object
461 462 463 464 |
# File 'lib/rbi/model.rb', line 461 def fully_qualified_names parent_name = parent_scope&.fully_qualified_name names.map { |name| "#{parent_name}##{name}=" } end |
#to_s ⇒ Object
467 468 469 470 |
# File 'lib/rbi/model.rb', line 467 def to_s symbols = names.map { |name| ":#{name}" }.join(", ") "#{parent_scope&.fully_qualified_name}.attr_writer(#{symbols})" end |