Class: RBI::Param

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

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

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

Constructor Details

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

Returns a new instance of Param.



560
561
562
563
# File 'lib/rbi/model.rb', line 560

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.



551
552
553
# File 'lib/rbi/model.rb', line 551

def name
  @name
end

Instance Method Details

#accept_printer(v) ⇒ Object



416
417
418
# File 'lib/rbi/printer.rb', line 416

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

#comments_linesObject



429
430
431
# File 'lib/rbi/printer.rb', line 429

def comments_lines
  comments.flat_map { |comment| comment.text.lines.map(&:strip) }
end


421
422
423
424
425
426
# File 'lib/rbi/printer.rb', line 421

def print_comment_leading_space(v, last:)
  v.printn
  v.printt
  v.print(" " * (name.size + 1))
  v.print(" ") unless last
end

#to_sObject



566
567
568
# File 'lib/rbi/model.rb', line 566

def to_s
  name
end