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

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



1066
1067
1068
1069
1070
1071
# File 'lib/rbi/model.rb', line 1066

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

: String?



1063
1064
1065
# File 'lib/rbi/model.rb', line 1063

def default
  @default
end

#nameObject (readonly)

: String



1057
1058
1059
# File 'lib/rbi/model.rb', line 1057

def name
  @name
end

#typeObject

: (Type | String)



1060
1061
1062
# File 'lib/rbi/model.rb', line 1060

def type
  @type
end

Instance Method Details

#compatible_with?(other) ⇒ Boolean

: (Node other) -> bool

Returns:

  • (Boolean)


556
557
558
# File 'lib/rbi/rewriters/merge_trees.rb', line 556

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)


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

def fully_qualified_names = raise NotImplementedError, "Abstract method called"