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: []) ⇒ TypeMember

Returns a new instance of TypeMember.



853
854
855
856
857
# File 'lib/rbi/model.rb', line 853

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

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



850
851
852
# File 'lib/rbi/model.rb', line 850

def name
  @name
end

#valueObject (readonly)

Returns the value of attribute value.



850
851
852
# File 'lib/rbi/model.rb', line 850

def value
  @value
end

Instance Method Details

#accept_printer(v) ⇒ Object



593
594
595
596
597
598
599
600
# File 'lib/rbi/printer.rb', line 593

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



860
861
862
863
# File 'lib/rbi/model.rb', line 860

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

#to_sObject



866
867
868
# File 'lib/rbi/model.rb', line 866

def to_s
  fully_qualified_name
end