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

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

Returns a new instance of TypeMember.



1210
1211
1212
1213
1214
1215
# File 'lib/rbi/model.rb', line 1210

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.



1199
1200
1201
# File 'lib/rbi/model.rb', line 1199

def name
  @name
end

#valueObject (readonly)

Returns the value of attribute value.



1199
1200
1201
# File 'lib/rbi/model.rb', line 1199

def value
  @value
end

Instance Method Details

#accept_printer(v) ⇒ Object



682
683
684
685
686
687
688
689
# File 'lib/rbi/printer.rb', line 682

def accept_printer(v)
  previous_node = v.previous_node
  v.printn if previous_node && (!previous_node.oneline? || !oneline?)

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

#fully_qualified_nameObject



1218
1219
1220
1221
# File 'lib/rbi/model.rb', line 1218

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

#to_sObject



1224
1225
1226
# File 'lib/rbi/model.rb', line 1224

def to_s
  fully_qualified_name
end