Class: RBI::TStructField
- Inherits:
-
NodeWithComments
- Object
- Node
- NodeWithComments
- RBI::TStructField
- Extended by:
- T::Helpers, T::Sig
- Defined in:
- lib/rbi/model.rb,
lib/rbi/printer.rb,
lib/rbi/rewriters/merge_trees.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#default ⇒ Object
Returns the value of attribute default.
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
Returns the value of attribute type.
Attributes inherited from NodeWithComments
Attributes inherited from Node
Instance Method Summary collapse
- #accept_printer(v) ⇒ Object
- #compatible_with?(other) ⇒ Boolean
- #fully_qualified_names ⇒ Object
-
#initialize(name, type, default: nil, loc: nil, comments: []) ⇒ TStructField
constructor
A new instance of TStructField.
Methods inherited from NodeWithComments
#annotations, #merge_with, #oneline?
Methods inherited from Node
#detach, #group_kind, #merge_with, #oneline?, #parent_conflict_tree, #parent_scope, #print, #print_blank_line_before, #replace, #string
Constructor Details
#initialize(name, type, default: nil, loc: nil, comments: []) ⇒ TStructField
Returns a new instance of TStructField.
1157 1158 1159 1160 1161 1162 |
# File 'lib/rbi/model.rb', line 1157 def initialize(name, type, default: nil, loc: nil, comments: []) super(loc: loc, comments: comments) @name = name @type = type @default = default end |
Instance Attribute Details
#default ⇒ Object
Returns the value of attribute default.
1146 1147 1148 |
# File 'lib/rbi/model.rb', line 1146 def default @default end |
#name ⇒ Object
Returns the value of attribute name.
1143 1144 1145 |
# File 'lib/rbi/model.rb', line 1143 def name @name end |
#type ⇒ Object
Returns the value of attribute type.
1143 1144 1145 |
# File 'lib/rbi/model.rb', line 1143 def type @type end |
Instance Method Details
#accept_printer(v) ⇒ Object
771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 |
# File 'lib/rbi/printer.rb', line 771 def accept_printer(v) print_blank_line_before(v) v.printl("# #{loc}") if loc && v.print_locs v.visit_all(comments) case self when TStructProp v.printt("prop") when TStructConst v.printt("const") end v.print(" :#{name}, #{type}") default = self.default v.print(", default: #{default}") if default v.printn end |
#compatible_with?(other) ⇒ Boolean
528 529 530 |
# File 'lib/rbi/rewriters/merge_trees.rb', line 528 def compatible_with?(other) other.is_a?(TStructField) && name == other.name && type == other.type && default == other.default end |
#fully_qualified_names ⇒ Object
1165 |
# File 'lib/rbi/model.rb', line 1165 def fully_qualified_names; end |