Class: RBI::Const
Overview
Instance Attribute Summary collapse
#comments
Attributes inherited from Node
#loc, #parent_tree
Instance Method Summary
collapse
#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, value, loc: nil, comments: nil, &block) ⇒ Const
Returns a new instance of Const.
301
302
303
304
305
306
|
# File 'lib/rbi/model.rb', line 301
def initialize(name, value, loc: nil, comments: nil, &block)
super(loc: loc, comments: )
@name = name.to_s @value = value
block&.call(self)
end
|
Instance Attribute Details
#name ⇒ Object
298
299
300
|
# File 'lib/rbi/model.rb', line 298
def name
@name
end
|
#value ⇒ Object
298
299
300
|
# File 'lib/rbi/model.rb', line 298
def value
@value
end
|
Instance Method Details
#compatible_with?(other) ⇒ Boolean
412
413
414
|
# File 'lib/rbi/rewriters/merge_trees.rb', line 412
def compatible_with?(other)
other.is_a?(Const) && name == other.name && value == other.value
end
|
#fully_qualified_name ⇒ Object
309
310
311
312
313
|
# File 'lib/rbi/model.rb', line 309
def fully_qualified_name
return name if name.start_with?("::")
"#{parent_scope&.fully_qualified_name}::#{name}"
end
|
#index_ids ⇒ Object
94
95
96
|
# File 'lib/rbi/index.rb', line 94
def index_ids
[fully_qualified_name]
end
|
#to_s ⇒ Object
317
318
319
|
# File 'lib/rbi/model.rb', line 317
def to_s
fully_qualified_name
end
|