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/printer.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
- #accept_printer(v) ⇒ Object
- #compatible_with?(other) ⇒ Boolean
- #fully_qualified_name ⇒ Object
- #index_ids ⇒ Object
-
#initialize(name, value, loc: nil, comments: []) ⇒ Const
constructor
A new instance of Const.
- #to_s ⇒ Object
Methods inherited from NodeWithComments
Methods inherited from Node
#detach, #group_kind, #merge_with, #oneline?, #parent_conflict_tree, #parent_scope, #print, #replace, #string
Constructor Details
#initialize(name, value, loc: nil, comments: []) ⇒ Const
Returns a new instance of Const.
253 254 255 256 257 |
# File 'lib/rbi/model.rb', line 253 def initialize(name, value, loc: nil, comments: []) super(loc: loc, comments: comments) @name = name @value = value end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
250 251 252 |
# File 'lib/rbi/model.rb', line 250 def name @name end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
250 251 252 |
# File 'lib/rbi/model.rb', line 250 def value @value end |
Instance Method Details
#accept_printer(v) ⇒ Object
259 260 261 262 263 264 265 266 |
# File 'lib/rbi/printer.rb', line 259 def accept_printer(v) previous_node = v.previous_node v.printn if previous_node && (!previous_node.oneline? || !oneline?) v.printl("# #{loc}") if loc && v.print_locs v.visit_all(comments) v.printl("#{name} = #{value}") end |
#compatible_with?(other) ⇒ Boolean
333 334 335 |
# File 'lib/rbi/rewriters/merge_trees.rb', line 333 def compatible_with?(other) other.is_a?(Const) && name == other.name && value == other.value end |
#fully_qualified_name ⇒ Object
260 261 262 263 |
# File 'lib/rbi/model.rb', line 260 def fully_qualified_name return name if name.start_with?("::") "#{parent_scope&.fully_qualified_name}::#{name}" end |
#index_ids ⇒ Object
92 93 94 |
# File 'lib/rbi/index.rb', line 92 def index_ids [fully_qualified_name] end |
#to_s ⇒ Object
266 267 268 |
# File 'lib/rbi/model.rb', line 266 def to_s fully_qualified_name end |