Class: RubyLsp::Requests::Support::Annotation
- Inherits:
-
Object
- Object
- RubyLsp::Requests::Support::Annotation
- Extended by:
- T::Sig
- Defined in:
- lib/ruby_lsp/requests/support/annotation.rb
Instance Attribute Summary collapse
-
#arity ⇒ Object
readonly
Returns the value of attribute arity.
-
#receiver ⇒ Object
readonly
Returns the value of attribute receiver.
Instance Method Summary collapse
-
#initialize(arity:, receiver: false) ⇒ Annotation
constructor
A new instance of Annotation.
- #supports_arity?(arity) ⇒ Boolean
- #supports_receiver?(receiver) ⇒ Boolean
Constructor Details
#initialize(arity:, receiver: false) ⇒ Annotation
Returns a new instance of Annotation.
15 16 17 18 |
# File 'lib/ruby_lsp/requests/support/annotation.rb', line 15 def initialize(arity:, receiver: false) @arity = arity @receiver = receiver end |
Instance Attribute Details
#arity ⇒ Object (readonly)
Returns the value of attribute arity.
21 22 23 |
# File 'lib/ruby_lsp/requests/support/annotation.rb', line 21 def arity @arity end |
#receiver ⇒ Object (readonly)
Returns the value of attribute receiver.
24 25 26 |
# File 'lib/ruby_lsp/requests/support/annotation.rb', line 24 def receiver @receiver end |
Instance Method Details
#supports_arity?(arity) ⇒ Boolean
27 28 29 30 31 32 33 34 35 |
# File 'lib/ruby_lsp/requests/support/annotation.rb', line 27 def supports_arity?(arity) if @arity.is_a?(Integer) @arity == arity elsif @arity.is_a?(Range) @arity.cover?(arity) else T.absurd(@arity) end end |
#supports_receiver?(receiver) ⇒ Boolean
38 39 40 41 42 |
# File 'lib/ruby_lsp/requests/support/annotation.rb', line 38 def supports_receiver?(receiver) return receiver.nil? || receiver.empty? if @receiver == false receiver == "T" end |