Class: TopSecret::Text::LabelSequence
- Inherits:
-
Object
- Object
- TopSecret::Text::LabelSequence
- Defined in:
- lib/top_secret/text/label_sequence.rb
Overview
Generates unique, sequenced label symbols for each label type.
Instance Method Summary collapse
-
#initialize ⇒ LabelSequence
constructor
Creates a new LabelSequence instance with all counters at zero.
-
#next_label(label_type) ⇒ Symbol
Returns the next sequenced label for the given label type.
Constructor Details
#initialize ⇒ LabelSequence
Creates a new LabelSequence instance with all counters at zero.
14 15 16 |
# File 'lib/top_secret/text/label_sequence.rb', line 14 def initialize @counters = Hash.new(0) end |
Instance Method Details
#next_label(label_type) ⇒ Symbol
Returns the next sequenced label for the given label type.
22 23 24 25 |
# File 'lib/top_secret/text/label_sequence.rb', line 22 def next_label(label_type) @counters[label_type] += 1 :"#{label_type}#{TopSecret::LABEL_DELIMITER}#{@counters[label_type]}" end |