Class: RBI::Const
- Inherits:
-
NodeWithComments
- Object
- Node
- NodeWithComments
- RBI::Const
- Extended by:
- T::Sig
- Includes:
- Indexable
- Defined in:
- lib/rbi/model.rb,
lib/rbi/index.rb,
lib/rbi/rewriters/merge_trees.rb
Overview
Consts
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Attributes inherited from NodeWithComments
Attributes inherited from Node
Instance Method Summary collapse
- #compatible_with?(other) ⇒ Boolean
- #fully_qualified_name ⇒ Object
- #index_ids ⇒ Object
-
#initialize(name, value, loc: nil, comments: [], &block) ⇒ Const
constructor
A new instance of Const.
- #to_s ⇒ Object
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, value, loc: nil, comments: [], &block) ⇒ Const
Returns a new instance of Const.
329 330 331 332 333 334 |
# File 'lib/rbi/model.rb', line 329 def initialize(name, value, loc: nil, comments: [], &block) super(loc: loc, comments: comments) @name = name @value = value block&.call(self) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
318 319 320 |
# File 'lib/rbi/model.rb', line 318 def name @name end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
318 319 320 |
# File 'lib/rbi/model.rb', line 318 def value @value end |
Instance Method Details
#compatible_with?(other) ⇒ Boolean
411 412 413 |
# File 'lib/rbi/rewriters/merge_trees.rb', line 411 def compatible_with?(other) other.is_a?(Const) && name == other.name && value == other.value end |
#fully_qualified_name ⇒ Object
337 338 339 340 341 |
# File 'lib/rbi/model.rb', line 337 def fully_qualified_name return name if name.start_with?("::") "#{parent_scope&.fully_qualified_name}::#{name}" end |
#index_ids ⇒ Object
103 104 105 |
# File 'lib/rbi/index.rb', line 103 def index_ids [fully_qualified_name] end |
#to_s ⇒ Object
344 345 346 |
# File 'lib/rbi/model.rb', line 344 def to_s fully_qualified_name end |