Class: Arboretum::DocTree::Counters::Counter
- Inherits:
-
Object
- Object
- Arboretum::DocTree::Counters::Counter
- Defined in:
- lib/arboretum/doctree.rb
Constant Summary collapse
- @@counters =
Hash.new{|h, name| h[name] = Counter.new(name)}
Instance Attribute Summary collapse
-
#current_value ⇒ Object
Returns the value of attribute current_value.
-
#gradient ⇒ Object
Returns the value of attribute gradient.
-
#incrementers ⇒ Object
Returns the value of attribute incrementers.
-
#name ⇒ Object
Returns the value of attribute name.
-
#resetters ⇒ Object
Returns the value of attribute resetters.
-
#start_value ⇒ Object
Returns the value of attribute start_value.
Class Method Summary collapse
Instance Method Summary collapse
- #increment ⇒ Object
-
#initialize(name) ⇒ Counter
constructor
A new instance of Counter.
- #reset ⇒ Object
Constructor Details
#initialize(name) ⇒ Counter
Returns a new instance of Counter.
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/arboretum/doctree.rb', line 17 def initialize(name) name = name.to_sym if !name.is_a?(Symbol) @name = name @incrementers = [] @resetters = [] @start_value = 1 @gradient = 1 @current_value = start_value end |
Instance Attribute Details
#current_value ⇒ Object
Returns the value of attribute current_value.
10 11 12 |
# File 'lib/arboretum/doctree.rb', line 10 def current_value @current_value end |
#gradient ⇒ Object
Returns the value of attribute gradient.
10 11 12 |
# File 'lib/arboretum/doctree.rb', line 10 def gradient @gradient end |
#incrementers ⇒ Object
Returns the value of attribute incrementers.
10 11 12 |
# File 'lib/arboretum/doctree.rb', line 10 def incrementers @incrementers end |
#name ⇒ Object
Returns the value of attribute name.
10 11 12 |
# File 'lib/arboretum/doctree.rb', line 10 def name @name end |
#resetters ⇒ Object
Returns the value of attribute resetters.
10 11 12 |
# File 'lib/arboretum/doctree.rb', line 10 def resetters @resetters end |
#start_value ⇒ Object
Returns the value of attribute start_value.
10 11 12 |
# File 'lib/arboretum/doctree.rb', line 10 def start_value @start_value end |
Class Method Details
.counters ⇒ Object
13 14 15 |
# File 'lib/arboretum/doctree.rb', line 13 def self.counters @@counters end |
Instance Method Details
#increment ⇒ Object
32 33 34 |
# File 'lib/arboretum/doctree.rb', line 32 def increment @current_value += gradient end |
#reset ⇒ Object
28 29 30 |
# File 'lib/arboretum/doctree.rb', line 28 def reset @current_value = start_value end |