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.
738 739 740 741 742 743 |
# File 'lib/rbi/model.rb', line 738 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.
727 728 729 |
# File 'lib/rbi/model.rb', line 727 def default @default end |
#name ⇒ Object
Returns the value of attribute name.
724 725 726 |
# File 'lib/rbi/model.rb', line 724 def name @name end |
#type ⇒ Object
Returns the value of attribute type.
724 725 726 |
# File 'lib/rbi/model.rb', line 724 def type @type end |
Instance Method Details
#accept_printer(v) ⇒ Object
553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 |
# File 'lib/rbi/printer.rb', line 553 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
455 456 457 |
# File 'lib/rbi/rewriters/merge_trees.rb', line 455 def compatible_with?(other) other.is_a?(TStructField) && name == other.name && type == other.type && default == other.default end |
#fully_qualified_names ⇒ Object
746 |
# File 'lib/rbi/model.rb', line 746 def fully_qualified_names; end |