class SystemCat::Version
Attributes
code[RW]
Public Class Methods
new(path = 'config/version.txt')
click to toggle source
# File lib/system_cat/version.rb, line 6 def initialize(path = 'config/version.txt') @path = path @code = File.read(@path).to_i end
Public Instance Methods
bump()
click to toggle source
# File lib/system_cat/version.rb, line 32 def bump return increment.save end
decrement()
click to toggle source
# File lib/system_cat/version.rb, line 11 def decrement @code = code - 1 return self end
increment()
click to toggle source
# File lib/system_cat/version.rb, line 16 def increment @code = code + 1 return self end
save()
click to toggle source
# File lib/system_cat/version.rb, line 21 def save File.open(@path, 'wb') { |io| io.write(@code) } end
to_s()
click to toggle source
# File lib/system_cat/version.rb, line 25 def to_s major = (code / 100).to_i minor = ((code % 100) / 10).to_i build = code % 10 return "#{major}.#{minor}.#{build}" end