Class: RBI::TEnumBlock
- Inherits:
-
NodeWithComments
show all
- Extended by:
- T::Sig
- Includes:
- Indexable
- Defined in:
- lib/rbi/index.rb,
lib/rbi/model.rb,
lib/rbi/printer.rb,
lib/rbi/rewriters/merge_trees.rb
Instance Attribute Summary collapse
#comments
Attributes inherited from Node
#loc, #parent_tree
Instance Method Summary
collapse
#annotations, #oneline?
Methods inherited from Node
#compatible_with?, #detach, #group_kind, #oneline?, #parent_conflict_tree, #parent_scope, #print, #print_blank_line_before, #replace, #string
Constructor Details
#initialize(names = [], loc: nil, comments: [], &block) ⇒ TEnumBlock
Returns a new instance of TEnumBlock.
1258
1259
1260
1261
1262
|
# File 'lib/rbi/model.rb', line 1258
def initialize(names = [], loc: nil, comments: [], &block)
super(loc: loc, comments: )
@names = names
block&.call(self)
end
|
Instance Attribute Details
#names ⇒ Object
Returns the value of attribute names.
1248
1249
1250
|
# File 'lib/rbi/model.rb', line 1248
def names
@names
end
|
Instance Method Details
#<<(name) ⇒ Object
1270
1271
1272
|
# File 'lib/rbi/model.rb', line 1270
def <<(name)
@names << name
end
|
#accept_printer(v) ⇒ Object
727
728
729
730
731
732
733
734
735
736
737
|
# File 'lib/rbi/printer.rb', line 727
def accept_printer(v)
v.printl("# #{loc}") if loc && v.print_locs
v.visit_all()
v.printl("enums do")
v.indent
names.each do |name|
v.printl("#{name} = new")
end
v.dedent
v.printl("end")
end
|
#empty? ⇒ Boolean
1265
1266
1267
|
# File 'lib/rbi/model.rb', line 1265
def empty?
names.empty?
end
|
#index_ids ⇒ Object
199
200
201
|
# File 'lib/rbi/index.rb', line 199
def index_ids
[to_s]
end
|
#merge_with(other) ⇒ Object
546
547
548
549
550
551
552
|
# File 'lib/rbi/rewriters/merge_trees.rb', line 546
def merge_with(other)
return unless other.is_a?(TEnumBlock)
super
other.names.each do |name|
names << name unless names.include?(name)
end
end
|
#to_s ⇒ Object
1275
1276
1277
|
# File 'lib/rbi/model.rb', line 1275
def to_s
"#{parent_scope&.fully_qualified_name}.enums"
end
|