Class: RBI::Const
- Inherits:
-
NodeWithComments
- Object
- Node
- NodeWithComments
- RBI::Const
- 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
: String.
-
#value ⇒ Object
readonly
: String.
Attributes inherited from NodeWithComments
Attributes inherited from Node
Instance Method Summary collapse
-
#compatible_with?(other) ⇒ Boolean
: (Node other) -> bool.
-
#fully_qualified_name ⇒ Object
: -> String.
-
#index_ids ⇒ Object
: -> Array.
-
#initialize(name, value, loc: nil, comments: [], &block) ⇒ Const
constructor
: (String name, String value, ?loc: Loc?, ?comments: Array) ?{ (Const node) -> void } -> void.
-
#to_s ⇒ Object
: -> String.
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
: (String name, String value, ?loc: Loc?, ?comments: Array) ?{ (Const node) -> void } -> void
268 269 270 271 272 273 |
# File 'lib/rbi/model.rb', line 268 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)
: String
265 266 267 |
# File 'lib/rbi/model.rb', line 265 def name @name end |
#value ⇒ Object (readonly)
: String
265 266 267 |
# File 'lib/rbi/model.rb', line 265 def value @value end |
Instance Method Details
#compatible_with?(other) ⇒ Boolean
: (Node other) -> bool
395 396 397 |
# File 'lib/rbi/rewriters/merge_trees.rb', line 395 def compatible_with?(other) other.is_a?(Const) && name == other.name && value == other.value end |
#fully_qualified_name ⇒ Object
: -> String
276 277 278 279 280 |
# File 'lib/rbi/model.rb', line 276 def fully_qualified_name return name if name.start_with?("::") "#{parent_scope&.fully_qualified_name}::#{name}" end |
#index_ids ⇒ Object
: -> Array
94 95 96 |
# File 'lib/rbi/index.rb', line 94 def index_ids [fully_qualified_name] end |
#to_s ⇒ Object
: -> String
284 285 286 |
# File 'lib/rbi/model.rb', line 284 def to_s fully_qualified_name end |