Class: Forall::Counter
- Inherits:
-
Object
- Object
- Forall::Counter
- Defined in:
- lib/forall/counter.rb
Instance Attribute Summary collapse
-
#fail ⇒ Object
Returns the value of attribute fail.
-
#labels ⇒ Object
readonly
Returns the value of attribute labels.
-
#no ⇒ Object
Returns the value of attribute no.
-
#ok ⇒ Object
Returns the value of attribute ok.
-
#shrunk ⇒ Object
readonly
Returns the value of attribute shrunk.
-
#skip ⇒ Object
Returns the value of attribute skip.
-
#steps ⇒ Object
Returns the value of attribute steps.
Instance Method Summary collapse
-
#initialize(top = true) ⇒ Counter
constructor
A new instance of Counter.
- #label!(*names) ⇒ Object
- #skip! ⇒ Object
- #test ⇒ Object
- #total ⇒ Object
Constructor Details
#initialize(top = true) ⇒ Counter
Returns a new instance of Counter.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/forall/counter.rb', line 9 def initialize(top = true) @ok = 0 @no = 0 @skip = 0 @fail = 0 @steps = 0 @shrunk = Counter.new(false) if top @labels = Hash.new{|h,k| h[k] = 0 } @private = nil end |
Instance Attribute Details
#fail ⇒ Object
Returns the value of attribute fail.
5 6 7 |
# File 'lib/forall/counter.rb', line 5 def fail @fail end |
#labels ⇒ Object (readonly)
Returns the value of attribute labels.
7 8 9 |
# File 'lib/forall/counter.rb', line 7 def labels @labels end |
#no ⇒ Object
Returns the value of attribute no.
5 6 7 |
# File 'lib/forall/counter.rb', line 5 def no @no end |
#ok ⇒ Object
Returns the value of attribute ok.
5 6 7 |
# File 'lib/forall/counter.rb', line 5 def ok @ok end |
#shrunk ⇒ Object (readonly)
Returns the value of attribute shrunk.
7 8 9 |
# File 'lib/forall/counter.rb', line 7 def shrunk @shrunk end |
#skip ⇒ Object
Returns the value of attribute skip.
5 6 7 |
# File 'lib/forall/counter.rb', line 5 def skip @skip end |
#steps ⇒ Object
Returns the value of attribute steps.
5 6 7 |
# File 'lib/forall/counter.rb', line 5 def steps @steps end |
Instance Method Details
#label!(*names) ⇒ Object
33 34 35 36 37 |
# File 'lib/forall/counter.rb', line 33 def label!(*names) names.each do |x| @labels[x] += 1 end end |
#skip! ⇒ Object
28 29 30 31 |
# File 'lib/forall/counter.rb', line 28 def skip! @skip += 1 throw :skip, true end |
#test ⇒ Object
24 25 26 |
# File 'lib/forall/counter.rb', line 24 def test @ok + @no + @fail end |
#total ⇒ Object
20 21 22 |
# File 'lib/forall/counter.rb', line 20 def total @ok + @no + @skip + @fail end |