Class: Forall::Counter

Inherits:
Object
  • Object
show all
Defined in:
lib/forall/counter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#failObject

Returns the value of attribute fail.



5
6
7
# File 'lib/forall/counter.rb', line 5

def fail
  @fail
end

#labelsObject (readonly)

Returns the value of attribute labels.



7
8
9
# File 'lib/forall/counter.rb', line 7

def labels
  @labels
end

#noObject

Returns the value of attribute no.



5
6
7
# File 'lib/forall/counter.rb', line 5

def no
  @no
end

#okObject

Returns the value of attribute ok.



5
6
7
# File 'lib/forall/counter.rb', line 5

def ok
  @ok
end

#shrunkObject (readonly)

Returns the value of attribute shrunk.



7
8
9
# File 'lib/forall/counter.rb', line 7

def shrunk
  @shrunk
end

#skipObject

Returns the value of attribute skip.



5
6
7
# File 'lib/forall/counter.rb', line 5

def skip
  @skip
end

#stepsObject

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

#testObject



24
25
26
# File 'lib/forall/counter.rb', line 24

def test
  @ok + @no + @fail
end

#totalObject



20
21
22
# File 'lib/forall/counter.rb', line 20

def total
  @ok + @no + @skip + @fail
end