Class: RBI::TypeMember

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

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

Returns a new instance of TypeMember.



1323
1324
1325
1326
1327
1328
# File 'lib/rbi/model.rb', line 1323

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

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



1312
1313
1314
# File 'lib/rbi/model.rb', line 1312

def name
  @name
end

#valueObject (readonly)

Returns the value of attribute value.



1312
1313
1314
# File 'lib/rbi/model.rb', line 1312

def value
  @value
end

Instance Method Details

#accept_printer(v) ⇒ Object



744
745
746
747
748
749
750
# File 'lib/rbi/printer.rb', line 744

def accept_printer(v)
  print_blank_line_before(v)

  v.printl("# #{loc}") if loc && v.print_locs
  v.visit_all(comments)
  v.printl("#{name} = #{value}")
end

#fully_qualified_nameObject



1331
1332
1333
1334
# File 'lib/rbi/model.rb', line 1331

def fully_qualified_name
  return name if name.start_with?("::")
  "#{parent_scope&.fully_qualified_name}::#{name}"
end

#to_sObject



1337
1338
1339
# File 'lib/rbi/model.rb', line 1337

def to_s
  fully_qualified_name
end