Class: RBI::Param

Inherits:
NodeWithComments show all
Extended by:
T::Sig
Defined in:
lib/rbi/model.rb,
lib/rbi/printer.rb

Direct Known Subclasses

BlockParam, KwParam, KwRestParam, OptParam, RestParam

Instance Attribute Summary collapse

Attributes inherited from NodeWithComments

#comments

Attributes inherited from Node

#loc, #parent_tree

Instance Method Summary collapse

Methods inherited from NodeWithComments

#merge_with, #oneline?

Methods inherited from Node

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

Constructor Details

#initialize(name, loc: nil, comments: []) ⇒ Param

Returns a new instance of Param.



435
436
437
438
# File 'lib/rbi/model.rb', line 435

def initialize(name, loc: nil, comments: [])
  super(loc: loc, comments: comments)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



432
433
434
# File 'lib/rbi/model.rb', line 432

def name
  @name
end

Instance Method Details

#==(other) ⇒ Object



446
447
448
449
# File 'lib/rbi/model.rb', line 446

def ==(other)
  return false unless other.instance_of?(Param)
  name == T.cast(other, Param).name
end

#accept_printer(v) ⇒ Object



372
373
374
# File 'lib/rbi/printer.rb', line 372

def accept_printer(v)
  v.print(name.to_s)
end


377
378
379
380
381
# File 'lib/rbi/printer.rb', line 377

def print_comment_leading_space(v)
  v.printn
  v.printt
  v.print(" " * (name.size + 2))
end

#to_sObject



441
442
443
# File 'lib/rbi/model.rb', line 441

def to_s
  name
end