class FFFFFF::Counter
Public Class Methods
new(path)
click to toggle source
# File lib/0xffffff.rb, line 17 def initialize(path) @path = Pathname(path) end
Public Instance Methods
count_up() { |count| ... }
click to toggle source
# File lib/0xffffff.rb, line 21 def count_up count = read yield count count += 1 write(count) end
Private Instance Methods
read()
click to toggle source
# File lib/0xffffff.rb, line 32 def read if @path.exist? @path.read.chomp.to_i else 0 end end
write(count)
click to toggle source
# File lib/0xffffff.rb, line 40 def write(count) open(@path, 'w') do |f| f.write count.to_s end end