Class: RBI::TStructProp

Inherits:
TStructField show all
Includes:
Indexable
Defined in:
lib/rbi/index.rb,
lib/rbi/model.rb,
lib/rbi/rewriters/merge_trees.rb

Instance Attribute Summary

Attributes inherited from TStructField

#default, #name, #type

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: [], &block) ⇒ TStructProp

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



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

def initialize(name, type, default: nil, loc: nil, comments: [], &block)
  super(name, type, default: default, loc: loc, comments: comments)
  block&.call(self)
end

Instance Method Details

#compatible_with?(other) ⇒ Boolean

: (Node other) -> bool

Returns:

  • (Boolean)


540
541
542
# File 'lib/rbi/rewriters/merge_trees.rb', line 540

def compatible_with?(other)
  other.is_a?(TStructProp) && super
end

#fully_qualified_namesObject

: -> Array



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

def fully_qualified_names
  parent_name = parent_scope&.fully_qualified_name
  ["#{parent_name}##{name}", "#{parent_name}##{name}="]
end

#index_idsObject

: -> Array



204
205
206
# File 'lib/rbi/index.rb', line 204

def index_ids
  fully_qualified_names
end

#to_sObject

: -> String



1081
1082
1083
# File 'lib/rbi/model.rb', line 1081

def to_s
  "#{parent_scope&.fully_qualified_name}.prop(:#{name})"
end