Class: RBI::SigParam

Inherits:
NodeWithComments show all
Extended by:
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

#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, type, loc: nil, comments: [], &block) ⇒ SigParam



988
989
990
991
992
993
# File 'lib/rbi/model.rb', line 988

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

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



977
978
979
# File 'lib/rbi/model.rb', line 977

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



977
978
979
# File 'lib/rbi/model.rb', line 977

def type
  @type
end

Instance Method Details

#==(other) ⇒ Object



996
997
998
# File 'lib/rbi/model.rb', line 996

def ==(other)
  other.is_a?(SigParam) && name == other.name && type == other.type
end

#accept_printer(v) ⇒ Object



625
626
627
# File 'lib/rbi/printer.rb', line 625

def accept_printer(v)
  v.print("#{name}: #{type}")
end


630
631
632
633
634
635
# File 'lib/rbi/printer.rb', line 630

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