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, #comments?, #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: nil) ⇒ TStructField

Returns a new instance of TStructField.

Signature:

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



1228
1229
1230
1231
1232
1233
# File 'lib/rbi/model.rb', line 1228

def initialize(name, type, default: nil, loc: nil, comments: nil)
  super(loc: loc, comments: comments)
  @name = name.to_s #: String
  @type = type
  @default = default
end

Instance Attribute Details

#defaultObject

Signature:

  • String?



1225
1226
1227
# File 'lib/rbi/model.rb', line 1225

def default
  @default
end

#nameObject (readonly)

Signature:

  • String



1219
1220
1221
# File 'lib/rbi/model.rb', line 1219

def name
  @name
end

#typeObject

Signature:

  • (Type | String)



1222
1223
1224
# File 'lib/rbi/model.rb', line 1222

def type
  @type
end

Instance Method Details

#compatible_with?(other) ⇒ Boolean

Signature:

  • (Node other) -> bool

Returns:

  • (Boolean)


599
600
601
# File 'lib/rbi/rewriters/merge_trees.rb', line 599

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.

Signature:

  • -> Array[String]

Raises:

  • (NotImplementedError)


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

def fully_qualified_names = raise NotImplementedError, "Abstract method called"