Class: Parlour::RbiGenerator::RbiObject Abstract
- Inherits:
-
Object
- Object
- Parlour::RbiGenerator::RbiObject
- Extended by:
- T::Helpers, T::Sig
- Defined in:
- lib/parlour/rbi_generator/rbi_object.rb
Overview
Instance Attribute Summary collapse
-
#comments ⇒ Array<String>
readonly
An array of comments which will be placed above the object in the RBI file.
-
#generated_by ⇒ Plugin?
readonly
The Plugin which was controlling the #generator when this object was created.
-
#generator ⇒ RbiGenerator
readonly
The generator which this object belongs to.
-
#name ⇒ String
readonly
The name of this object.
Instance Method Summary collapse
-
#add_comment(comment) ⇒ void
(also: #add_comments)
Adds one or more comments to this RBI object.
-
#describe ⇒ String
abstract
Returns a human-readable brief string description of this object.
-
#generate_rbi(indent_level, options) ⇒ Array<String>
abstract
Generates the RBI lines for this object.
-
#initialize(generator, name) ⇒ void
constructor
Creates a new RBI object.
-
#merge_into_self(others) ⇒ void
abstract
Given an array of other objects, merges them into this one.
-
#mergeable?(others) ⇒ Boolean
abstract
Given an array of other objects, returns true if they may be merged into this instance using #merge_into_self.
Constructor Details
#initialize(generator, name) ⇒ void
Don’t call this directly.
Creates a new RBI object.
21 22 23 24 25 26 |
# File 'lib/parlour/rbi_generator/rbi_object.rb', line 21 def initialize(generator, name) @generator = generator @generated_by = generator.current_plugin @name = name @comments = [] end |
Instance Attribute Details
#comments ⇒ Array<String> (readonly)
An array of comments which will be placed above the object in the RBI file.
48 49 50 |
# File 'lib/parlour/rbi_generator/rbi_object.rb', line 48 def comments @comments end |
#generated_by ⇒ Plugin? (readonly)
The Plugin which was controlling the #generator when this object was created.
37 38 39 |
# File 'lib/parlour/rbi_generator/rbi_object.rb', line 37 def generated_by @generated_by end |
#generator ⇒ RbiGenerator (readonly)
The generator which this object belongs to.
31 32 33 |
# File 'lib/parlour/rbi_generator/rbi_object.rb', line 31 def generator @generator end |
#name ⇒ String (readonly)
The name of this object.
42 43 44 |
# File 'lib/parlour/rbi_generator/rbi_object.rb', line 42 def name @name end |
Instance Method Details
#add_comment(comment) ⇒ void Also known as: add_comments
This method returns an undefined value.
Adds one or more comments to this RBI object. Comments always go above the definition for this object, not in the definition’s body.
66 67 68 69 70 71 72 |
# File 'lib/parlour/rbi_generator/rbi_object.rb', line 66 def add_comment(comment) if comment.is_a?(String) comments << comment elsif comment.is_a?(Array) comments.concat(comment) end end |
#describe ⇒ String
Returns a human-readable brief string description of this object. This is displayed during manual conflict resolution with the parlour
CLI.
124 |
# File 'lib/parlour/rbi_generator/rbi_object.rb', line 124 def describe; end |
#generate_rbi(indent_level, options) ⇒ Array<String>
Generates the RBI lines for this object.
88 |
# File 'lib/parlour/rbi_generator/rbi_object.rb', line 88 def generate_rbi(indent_level, ); end |
#merge_into_self(others) ⇒ void
This method returns an undefined value.
Given an array of other objects, merges them into this one. Each subclass will do this differently. You MUST ensure that #mergeable? is true for those instances.
116 |
# File 'lib/parlour/rbi_generator/rbi_object.rb', line 116 def merge_into_self(others); end |
#mergeable?(others) ⇒ Boolean
Given an array of other objects, returns true if they may be merged into this instance using #merge_into_self. Each subclass will have its own criteria on what allows objects to be mergeable.
102 |
# File 'lib/parlour/rbi_generator/rbi_object.rb', line 102 def mergeable?(others); end |