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: nil, &block) ⇒ Const
constructor
: (String name, String value, ?loc: Loc?, ?comments: Array?) ?{ (Const node) -> void } -> void.
-
#to_s ⇒ Object
: -> String.
Methods inherited from NodeWithComments
#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
: (String name, String value, ?loc: Loc?, ?comments: Array?) ?{ (Const node) -> void } -> void
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: comments) @name = name.to_s #: String @value = value block&.call(self) end |
Instance Attribute Details
#name ⇒ Object (readonly)
: String
298 299 300 |
# File 'lib/rbi/model.rb', line 298 def name @name end |
#value ⇒ Object (readonly)
: String
298 299 300 |
# File 'lib/rbi/model.rb', line 298 def value @value end |
Instance Method Details
#compatible_with?(other) ⇒ Boolean
: (Node other) -> bool
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
: -> String
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
: -> Array
94 95 96 |
# File 'lib/rbi/index.rb', line 94 def index_ids [fully_qualified_name] end |
#to_s ⇒ Object
: -> String
317 318 319 |
# File 'lib/rbi/model.rb', line 317 def to_s fully_qualified_name end |