Class: RBI::Send

Inherits:
NodeWithComments show all
Extended by:
T::Sig
Includes:
Indexable
Defined in:
lib/rbi/model.rb,
lib/rbi/index.rb,
lib/rbi/printer.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, #oneline?

Methods inherited from Node

#detach, #group_kind, #merge_with, #oneline?, #parent_conflict_tree, #parent_scope, #print, #print_blank_line_before, #replace, #string

Constructor Details

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

Returns a new instance of Send.



937
938
939
940
941
942
# File 'lib/rbi/model.rb', line 937

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)

Returns the value of attribute args.



926
927
928
# File 'lib/rbi/model.rb', line 926

def args
  @args
end

#methodObject (readonly)

Returns the value of attribute method.



923
924
925
# File 'lib/rbi/model.rb', line 923

def method
  @method
end

Instance Method Details

#<<(arg) ⇒ Object



945
946
947
# File 'lib/rbi/model.rb', line 945

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

#==(other) ⇒ Object



950
951
952
# File 'lib/rbi/model.rb', line 950

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

#accept_printer(v) ⇒ Object



562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
# File 'lib/rbi/printer.rb', line 562

def accept_printer(v)
  print_blank_line_before(v)

  v.printl("# #{loc}") if loc && v.print_locs
  v.visit_all(comments)
  v.printt(method)
  unless args.empty?
    v.print(" ")
    args.each_with_index do |arg, index|
      v.visit(arg)
      v.print(", ") if index < args.size - 1
    end
  end
  v.printn
end

#compatible_with?(other) ⇒ Boolean

Returns:

  • (Boolean)


519
520
521
# File 'lib/rbi/rewriters/merge_trees.rb', line 519

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

#index_idsObject



169
170
171
# File 'lib/rbi/index.rb', line 169

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

#to_sObject



955
956
957
# File 'lib/rbi/model.rb', line 955

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