Class: RBI::TStructField Abstract

Inherits:
NodeWithComments show all
Defined in:
lib/rbi/model.rb,
lib/rbi/rewriters/merge_trees.rb

Overview

This class is abstract.

Direct Known Subclasses

TStructConst, TStructProp

Instance Attribute Summary collapse

Attributes inherited from NodeWithComments

#comments

Attributes inherited from Node

#loc, #parent_tree

Instance Method Summary collapse

Methods inherited from NodeWithComments

#annotations, #merge_with, #version_requirements

Methods inherited from Node

#detach, #merge_with, #parent_conflict_tree, #parent_scope, #print, #rbs_print, #rbs_string, #replace, #satisfies_version?, #string

Constructor Details

#initialize(name, type, default: nil, loc: nil, comments: []) ⇒ TStructField

: (String name, (Type | String) type, ?default: String?, ?loc: Loc?, ?comments: Array) -> void



1020
1021
1022
1023
1024
1025
# File 'lib/rbi/model.rb', line 1020

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

Instance Attribute Details

#defaultObject

: String?



1017
1018
1019
# File 'lib/rbi/model.rb', line 1017

def default
  @default
end

#nameObject

: String



1011
1012
1013
# File 'lib/rbi/model.rb', line 1011

def name
  @name
end

#typeObject

: (Type | String)



1014
1015
1016
# File 'lib/rbi/model.rb', line 1014

def type
  @type
end

Instance Method Details

#compatible_with?(other) ⇒ Boolean

: (Node other) -> bool

Returns:

  • (Boolean)


524
525
526
# File 'lib/rbi/rewriters/merge_trees.rb', line 524

def compatible_with?(other)
  other.is_a?(TStructField) && name == other.name && type == other.type && default == other.default
end

#fully_qualified_namesObject

This method is abstract.

: -> Array

Raises:

  • (NotImplementedError)


1029
# File 'lib/rbi/model.rb', line 1029

def fully_qualified_names = raise NotImplementedError, "Abstract method called"