Class: Arboretum::DocTree::Counters::Counter

Inherits:
Object
  • Object
show all
Defined in:
lib/arboretum/doctree.rb

Constant Summary collapse

@@counters =
Hash.new{|h, name| h[name] = Counter.new(name)}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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_valueObject

Returns the value of attribute current_value.



10
11
12
# File 'lib/arboretum/doctree.rb', line 10

def current_value
  @current_value
end

#gradientObject

Returns the value of attribute gradient.



10
11
12
# File 'lib/arboretum/doctree.rb', line 10

def gradient
  @gradient
end

#incrementersObject

Returns the value of attribute incrementers.



10
11
12
# File 'lib/arboretum/doctree.rb', line 10

def incrementers
  @incrementers
end

#nameObject

Returns the value of attribute name.



10
11
12
# File 'lib/arboretum/doctree.rb', line 10

def name
  @name
end

#resettersObject

Returns the value of attribute resetters.



10
11
12
# File 'lib/arboretum/doctree.rb', line 10

def resetters
  @resetters
end

#start_valueObject

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

.countersObject



13
14
15
# File 'lib/arboretum/doctree.rb', line 13

def self.counters
  @@counters
end

Instance Method Details

#incrementObject



32
33
34
# File 'lib/arboretum/doctree.rb', line 32

def increment
  @current_value += gradient
end

#resetObject



28
29
30
# File 'lib/arboretum/doctree.rb', line 28

def reset
  @current_value = start_value
end