Class: Rigor::SigGen::MethodCandidate
- Inherits:
-
Object
- Object
- Rigor::SigGen::MethodCandidate
- Defined in:
- lib/rigor/sig_gen/method_candidate.rb
Overview
Per-method record produced by the generator.
classification is one of the Classification constants; the remaining fields are populated only when
applicable to that classification.
path— the source.rbfile the def came from.class_name— qualified receiver class name (e.g."Foo::Bar").nilfor top-level / DSL-block defs the MVP skips.method_name— the def'sSymbolname.kind—:instanceor:singleton.inferred_return—Rigor::Typeinstance (ornilwhen the inference pass disqualified the def).declared_return_rbs— the existing RBS-declared return spelling, ornilwhen no RBS declares the method.rbs— the rendered RBS one-liner the generator would emit (nilfor skipped / equivalent rows).skip_reason— one of Classification::SKIP_DIAGNOSTIC_IDS keys when classification is:skipped, elsenil.
Instance Attribute Summary collapse
-
#class_name ⇒ Object
readonly
Returns the value of attribute class_name.
-
#class_shells ⇒ Object
readonly
Returns the value of attribute class_shells.
-
#class_superclasses ⇒ Object
readonly
Returns the value of attribute class_superclasses.
-
#classification ⇒ Object
readonly
Returns the value of attribute classification.
-
#declared_return_rbs ⇒ Object
readonly
Returns the value of attribute declared_return_rbs.
-
#inferred_return ⇒ Object
readonly
Returns the value of attribute inferred_return.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#method_name ⇒ Object
readonly
Returns the value of attribute method_name.
-
#namespace_kinds ⇒ Object
readonly
Returns the value of attribute namespace_kinds.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#rbs ⇒ Object
readonly
Returns the value of attribute rbs.
-
#skip_reason ⇒ Object
readonly
Returns the value of attribute skip_reason.
Instance Method Summary collapse
-
#initialize(path:, class_name:, method_name:, kind:, classification:, inferred_return: nil, declared_return_rbs: nil, rbs: nil, skip_reason: nil, namespace_kinds: {}, class_shells: [], class_superclasses: {}) ⇒ MethodCandidate
constructor
rubocop:disable Metrics/ParameterLists.
- #to_h ⇒ Object
Constructor Details
#initialize(path:, class_name:, method_name:, kind:, classification:, inferred_return: nil, declared_return_rbs: nil, rbs: nil, skip_reason: nil, namespace_kinds: {}, class_shells: [], class_superclasses: {}) ⇒ MethodCandidate
rubocop:disable Metrics/ParameterLists
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rigor/sig_gen/method_candidate.rb', line 26 def initialize(path:, class_name:, method_name:, kind:, classification:, # rubocop:disable Metrics/ParameterLists inferred_return: nil, declared_return_rbs: nil, rbs: nil, skip_reason: nil, namespace_kinds: {}, class_shells: [], class_superclasses: {}) @path = path @class_name = class_name @method_name = method_name @kind = kind @classification = classification @inferred_return = inferred_return @declared_return_rbs = declared_return_rbs @rbs = rbs @skip_reason = skip_reason @namespace_kinds = namespace_kinds.freeze @class_shells = class_shells.freeze # Qualified-class-name => superclass source token (e.g. `{ "Foo::Bar" => "Base" }`). Only plain-constant # superclasses appear; computed ones are absent. The Writer emits `class Bar < Base` for the leaf when # present. @class_superclasses = class_superclasses.freeze freeze end |
Instance Attribute Details
#class_name ⇒ Object (readonly)
Returns the value of attribute class_name.
22 23 24 |
# File 'lib/rigor/sig_gen/method_candidate.rb', line 22 def class_name @class_name end |
#class_shells ⇒ Object (readonly)
Returns the value of attribute class_shells.
22 23 24 |
# File 'lib/rigor/sig_gen/method_candidate.rb', line 22 def class_shells @class_shells end |
#class_superclasses ⇒ Object (readonly)
Returns the value of attribute class_superclasses.
22 23 24 |
# File 'lib/rigor/sig_gen/method_candidate.rb', line 22 def class_superclasses @class_superclasses end |
#classification ⇒ Object (readonly)
Returns the value of attribute classification.
22 23 24 |
# File 'lib/rigor/sig_gen/method_candidate.rb', line 22 def classification @classification end |
#declared_return_rbs ⇒ Object (readonly)
Returns the value of attribute declared_return_rbs.
22 23 24 |
# File 'lib/rigor/sig_gen/method_candidate.rb', line 22 def declared_return_rbs @declared_return_rbs end |
#inferred_return ⇒ Object (readonly)
Returns the value of attribute inferred_return.
22 23 24 |
# File 'lib/rigor/sig_gen/method_candidate.rb', line 22 def inferred_return @inferred_return end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
22 23 24 |
# File 'lib/rigor/sig_gen/method_candidate.rb', line 22 def kind @kind end |
#method_name ⇒ Object (readonly)
Returns the value of attribute method_name.
22 23 24 |
# File 'lib/rigor/sig_gen/method_candidate.rb', line 22 def method_name @method_name end |
#namespace_kinds ⇒ Object (readonly)
Returns the value of attribute namespace_kinds.
22 23 24 |
# File 'lib/rigor/sig_gen/method_candidate.rb', line 22 def namespace_kinds @namespace_kinds end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
22 23 24 |
# File 'lib/rigor/sig_gen/method_candidate.rb', line 22 def path @path end |
#rbs ⇒ Object (readonly)
Returns the value of attribute rbs.
22 23 24 |
# File 'lib/rigor/sig_gen/method_candidate.rb', line 22 def rbs @rbs end |
#skip_reason ⇒ Object (readonly)
Returns the value of attribute skip_reason.
22 23 24 |
# File 'lib/rigor/sig_gen/method_candidate.rb', line 22 def skip_reason @skip_reason end |
Instance Method Details
#to_h ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/rigor/sig_gen/method_candidate.rb', line 47 def to_h { file: path, class: class_name, method: method_name.to_s, kind: kind.to_s, classification: classification.to_s, rbs: rbs, inferred_return: inferred_return&.erase_to_rbs, declared_return_rbs: declared_return_rbs, skip_reason: skip_reason ? Classification::SKIP_DIAGNOSTIC_IDS.fetch(skip_reason) : nil }.compact end |