Class: RBI::TypeMember
- Inherits:
-
NodeWithComments
- Object
- Node
- NodeWithComments
- RBI::TypeMember
- Extended by:
- T::Sig
- Defined in:
- lib/rbi/model.rb,
lib/rbi/printer.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Attributes inherited from NodeWithComments
Attributes inherited from Node
Instance Method Summary collapse
- #accept_printer(v) ⇒ Object
- #fully_qualified_name ⇒ Object
-
#initialize(name, value, loc: nil, comments: [], &block) ⇒ TypeMember
constructor
A new instance of TypeMember.
- #to_s ⇒ Object
Methods inherited from NodeWithComments
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
#name ⇒ Object (readonly)
Returns the value of attribute name.
1199 1200 1201 |
# File 'lib/rbi/model.rb', line 1199 def name @name end |
#value ⇒ Object (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_name ⇒ Object
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_s ⇒ Object
1224 1225 1226 |
# File 'lib/rbi/model.rb', line 1224 def to_s fully_qualified_name end |