Sha256: bc48bce373cb5718c35fc49eb22dd69b7d772477519e487db09d399638d1171c
Contents?: true
Size: 569 Bytes
Versions: 6
Compression:
Stored size: 569 Bytes
Contents
class String def increment_version array = self.split('.') digits = 0 index_of_last_digit = 0 array.each_with_index {|x, i| if x.is_number? then digits += 1 index_of_last_digit = i end break if (digits==3 || i==array.count-1) && x.is_number? } array[index_of_last_digit] = (array[index_of_last_digit].to_i + 1).to_s $stdout.puts 'Incrementing version...' array.join('.') end def increment_version! replace increment_version end def is_number? true if Float(self) rescue false end end
Version data entries
6 entries across 6 versions & 1 rubygems