Class: Ferro::Sequence
- Inherits:
-
Object
- Object
- Ferro::Sequence
- Defined in:
- opal/opal-ferro/ferro_sequence.js.rb
Overview
A helper class to generate unique labels. These labels can be used to ensure unique instance variable names.
Instance Method Summary collapse
-
#initialize(prefix = nil) ⇒ Sequence
constructor
Create a new sequence.
-
#next ⇒ String
Get the next label.
Constructor Details
#initialize(prefix = nil) ⇒ Sequence
Create a new sequence.
10 11 12 13 |
# File 'opal/opal-ferro/ferro_sequence.js.rb', line 10 def initialize(prefix = nil) @prefix = prefix @next_id = 0 end |
Instance Method Details
#next ⇒ String
Get the next label.
18 19 20 21 |
# File 'opal/opal-ferro/ferro_sequence.js.rb', line 18 def next @next_id += 1 "#{@prefix}#{@next_id}" end |