Class: Kitchen::Counter

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

Overview

A simple counting object

hehe

Instance Method Summary collapse

Constructor Details

#initializeCounter

Creates a new Counter instance



10
11
12
# File 'lib/kitchen/counter.rb', line 10

def initialize
  reset
end

Instance Method Details

#getInteger

Returns the value of the counter

Returns:



29
30
31
# File 'lib/kitchen/counter.rb', line 29

def get
  @value
end

#increment(by: 1) ⇒ Object Also known as: inc

Increase the value of the counter

Parameters:

  • by (Integer) (defaults to: 1)

    the amount to increase by



18
19
20
# File 'lib/kitchen/counter.rb', line 18

def increment(by: 1)
  @value += by
end

#reset(to: 0) ⇒ Object

Reset the value of the counter

Parameters:

  • to (Integer) (defaults to: 0)

    the value to reset to



36
37
38
# File 'lib/kitchen/counter.rb', line 36

def reset(to: 0)
  @value = to
end