Sha256: a8b5f57a2ed3a52e978e2eebd09ae776af71aa891495d5f0feafdf5b40d3d5cc

Contents?: true

Size: 379 Bytes

Versions: 1

Compression:

Stored size: 379 Bytes

Contents

module Whitespace
  class Counter
    def initialize
      @value = 0
    end

    def increment
      @value += 1
    end

    def change_to(new_value)
      new_value = new_value.to_i
      if new_value >= 0
        @value = new_value
      else
        raise ArgumentError, "must be non-negative: #{new_value}"
      end
    end

    def to_int
      @value
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
whitespace-ruby-1.0.0 lib/whitespace/data_structures/counter.rb