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
Methods inherited from Node
#detach, #group_kind, #merge_with, #oneline?, #parent_conflict_tree, #parent_scope, #print, #replace, #string
Constructor Details
#initialize(name, type, default: nil, loc: nil, comments: []) ⇒ TStructField
Returns a new instance of TStructField.
1041 1042 1043 1044 1045 1046 |
# File 'lib/rbi/model.rb', line 1041 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.
1030 1031 1032 |
# File 'lib/rbi/model.rb', line 1030 def default @default end |
#name ⇒ Object
Returns the value of attribute name.
1027 1028 1029 |
# File 'lib/rbi/model.rb', line 1027 def name @name end |
#type ⇒ Object
Returns the value of attribute type.
1027 1028 1029 |
# File 'lib/rbi/model.rb', line 1027 def type @type end |
Instance Method Details
#accept_printer(v) ⇒ Object
642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 |
# File 'lib/rbi/printer.rb', line 642 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) 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
495 496 497 |
# File 'lib/rbi/rewriters/merge_trees.rb', line 495 def compatible_with?(other) other.is_a?(TStructField) && name == other.name && type == other.type && default == other.default end |
#fully_qualified_names ⇒ Object
1049 |
# File 'lib/rbi/model.rb', line 1049 def fully_qualified_names; end |