mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
24 lines
No EOL
344 B
Ruby
24 lines
No EOL
344 B
Ruby
class Counter
|
|
def initialize value = 0
|
|
@value = value
|
|
end
|
|
attr_accessor :value
|
|
def method_missing *args, &blk
|
|
@value.send(*args, &blk)
|
|
end
|
|
def to_s
|
|
@value.to_s
|
|
end
|
|
|
|
def now
|
|
@value
|
|
end
|
|
|
|
# pre-increment ".+" when x not present
|
|
def next(x = 1)
|
|
@value += x
|
|
end
|
|
def prev(x = 1)
|
|
@value -= x
|
|
end
|
|
end |