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
275 276 277 278 279 280 |
# File 'lib/rbi/model.rb', line 275 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
272 273 274 |
# File 'lib/rbi/model.rb', line 272 def name @name end |
#value ⇒ Object (readonly)
: String
272 273 274 |
# File 'lib/rbi/model.rb', line 272 def value @value end |
Instance Method Details
#compatible_with?(other) ⇒ Boolean
: (Node other) -> bool
386 387 388 |
# File 'lib/rbi/rewriters/merge_trees.rb', line 386 def compatible_with?(other) other.is_a?(Const) && name == other.name && value == other.value end |
#fully_qualified_name ⇒ Object
: -> String
283 284 285 286 287 |
# File 'lib/rbi/model.rb', line 283 def fully_qualified_name return name if name.start_with?("::") "#{parent_scope&.fully_qualified_name}::#{name}" end |
#index_ids ⇒ Object
: -> Array
99 100 101 |
# File 'lib/rbi/index.rb', line 99 def index_ids [fully_qualified_name] end |
#to_s ⇒ Object
: -> String
291 292 293 |
# File 'lib/rbi/model.rb', line 291 def to_s fully_qualified_name end |