Class: RBI::Send

Inherits:
NodeWithComments show all
Includes:
Indexable
Defined in:
lib/rbi/model.rb,
lib/rbi/index.rb,
lib/rbi/rewriters/merge_trees.rb

Overview

Sends

Instance Attribute Summary collapse

Attributes inherited from NodeWithComments

#comments

Attributes inherited from Node

#loc, #parent_tree

Instance Method Summary collapse

Methods inherited from NodeWithComments

#annotations, #merge_with, #version_requirements

Methods inherited from Node

#detach, #merge_with, #parent_conflict_tree, #parent_scope, #print, #rbs_print, #rbs_string, #replace, #satisfies_version?, #string

Constructor Details

#initialize(method, args = [], loc: nil, comments: [], &block) ⇒ Send

: (String method, ?Array args, ?loc: Loc?, ?comments: Array) ?{ (Send node) -> void } -> void



779
780
781
782
783
784
# File 'lib/rbi/model.rb', line 779

def initialize(method, args = [], loc: nil, comments: [], &block)
  super(loc: loc, comments: comments)
  @method = method
  @args = args
  block&.call(self)
end

Instance Attribute Details

#argsObject (readonly)

: Array



776
777
778
# File 'lib/rbi/model.rb', line 776

def args
  @args
end

#methodObject (readonly)

: String



773
774
775
# File 'lib/rbi/model.rb', line 773

def method
  @method
end

Instance Method Details

#<<(arg) ⇒ Object

: (Arg arg) -> void



787
788
789
# File 'lib/rbi/model.rb', line 787

def <<(arg)
  @args << arg
end

#==(other) ⇒ Object

: (Object? other) -> bool



792
793
794
# File 'lib/rbi/model.rb', line 792

def ==(other)
  Send === other && method == other.method && args == other.args
end

#compatible_with?(other) ⇒ Boolean

: (Node other) -> bool

Returns:

  • (Boolean)


503
504
505
# File 'lib/rbi/rewriters/merge_trees.rb', line 503

def compatible_with?(other)
  other.is_a?(Send) && method == other.method && args == other.args
end

#index_idsObject

: -> Array



189
190
191
# File 'lib/rbi/index.rb', line 189

def index_ids
  ["#{parent_scope&.fully_qualified_name}.#{method}"]
end

#to_sObject

: -> String



797
798
799
# File 'lib/rbi/model.rb', line 797

def to_s
  "#{parent_scope&.fully_qualified_name}.#{method}(#{args.join(", ")})"
end